home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 February
/
Chip_2002-02_cd1.bin
/
sharewar
/
apaths
/
APSOURCE.ZIP
/
PickApp.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-03-26
|
2KB
|
75 lines
/* PickApp - March 26th, 2001
**
** Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
**
** This function displays the standard MS Windows 95/NT file
** browser dialog box and allows the user to select a file.
**
** Called: w = window handle to the parent.
** filespec = a pointer to the file name buffer
**
** Returns: TRUE upon success, or FALSE if an error exists
** or the user pressed the [Cancel] button.
**
** The "filespec" buffer passed as an arguement to this
** routine will contain the user's file selection. This
** file name will include the full drive, path and
** file specification.
*/
#include "AppPaths.h"
#define CAPTION "Select an Application"
#define FILTER "Application Files|*.exe;*.com;*.bat;*.lnk|All Files|*.*|"
#define DELIMITER '|'
extern BOOL far PickApp (HWND w,LPSTR filespec)
{
static DWORD finx = 1;
auto OPENFILENAME fn = { sizeof (OPENFILENAME) };
auto char filter[PSTRING];
auto char filename[PSTRING];
auto int index;
auto BOOL good;
lstrcpy (filename,filespec);
lstrcpy (filter,FILTER);
for (index = NIL; filter[index]; index++)
if (filter[index] == DELIMITER)
filter[index] = EOS;
fn.hInstance = applet;
fn.hwndOwner = w;
fn.lpstrFilter = filter;
fn.nFilterIndex = finx;
fn.lpstrFile = filename;
fn.nMaxFile = PSTRING;
fn.nMaxFileTitle = PSTRING;
fn.lpstrTitle = CAPTION;
fn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST
| OFN_EXPLORER | OFN_HIDEREADONLY;
good = GetOpenFileName (&fn);
UpdateWindow (w);
if (!good) return (FALSE);
lstrcpy (filespec,fn.lpstrFile);
finx = fn.nFilterIndex;
return (TRUE);
}
/* end of PickApp.c - written by Gregory Braun */