WinFileDlg
This function creates and displays the file dialog and returns the user's selection or selections.
Syntax
WinFileDlg(hwndP, hwndO, pfild)
Parameters
- hwndP (HWND) - input
- Parent-window handle of the created dialog window.
- HWND_DESKTOP - The desktop window.
- Other - Specified window.
- hwndO (HWND) - input
- Requested owner-window handle of the created dialog window.
- The actual owner window is calculated using the algorithm specified in the description of the WinLoadDlg function.
- pfild (PFILEDLG) - input
- Pointer to a FILEDLG structure.
Returns
- hwndDlg (HWND) - returns
- File dialog window handle.
- If the flag is set by the application, the return value is the window handle of the file dialog, or NULLHANDLE if the dialog cannot be created. If the flag is not set, the return value is TRUE if dialog creation is successful, or NULLHANDLE if it is unsuccessful.
Remarks
The pfild parameter is required and the FILEDLG structure must be properly initialized.
On return, the FILEDLG structure is updated with any user alterations, and the field is set to the value returned by the file dialog's WinDismissDlg function. By default, this is the ID of the push button pressed to dismiss the dialog, DID_OK or DID_CANCEL, unless the application supplied additional push buttons in its template.
For convenience, the pointer to the FILEDLG structure is placed in the QWL_USER field of the dialog's frame window. If in a custom file dialog procedure the pointer to the FILEDLG structure is desired, it should be queried from the frame window with the WinQueryWindowULong function.
To subclass the default file dialog with a new template, the application must give the module and ID of the new file dialog template and the address of a dialog procedure for message handling. Window IDs in the range 0x0000 through 0x0FFF are reserved for the standard file dialog controls. IDs from outside this range must be chosen for any controls or windows added to a custom file dialog.
When a modeless dialog is dismissed, the owner of the file dialog will receive a WM_COMMAND message with the ID of the file dialog.
Example Code
This example uses WinFileDlg to create and display a single file selection dialog using the system default open file dialog template and procedure.
#define INCL_WINSTDFILE /* Window Standard File */ /* functions */ #include <os2.h> FILEDLG fild; /* File dialog info structure */ char pszTitle[10] = "Open File"; /* Title of dialog */ char pszFullFile[CCHMAXPATH] = "*.C"; /* File filter string */ HWND hwndMain; /* Window that owns the file */ /* dialog */ HWND hwndDlg; /* File dialog window */ /* Initially set all fields to 0 */ memset(&pfdFiledlg, 0, sizeof(FILEDLG)); /* Initialize those fields in the FILEDLG structure */ /* that are used by the application */ fild.cbSize = sizeof(FILEDLG); /* Size of structure */ fild.fl = FDS_HELPBUTTON | /* FDS_* flags */ FDS_CENTER | FDS_OPEN_DIALOG; fild.pszTitle = pszTitle; /* Dialog title string */ /* Initial path, file name, or file filter */ strcpy(fild.szFullFile, pszFullFile); /* Display the dialog and get the file */ hwndDlg = WinFileDlg(HWND_DESKTOP, hwndMain, &fild); if (hwndDlg && (pfild.lReturn == DID_OK)) { /* Upon successful return of a file, open it for reading */ /* and further processing */ }