Standard Dialogs

OS/2 Version 2.0 provides standard dialog boxes for handling the selection of files and fonts. These dialogs conform to SAA CUA guidelines, and are implemented within Presentation Manager. Applications are therefore not required to explicitly design and code such dialog functions, nor to modify them should the CUA guidelines change in the future.

The standard dialogs are displayed using two Presentation Manager functions new to OS/2 Version 2.0; these are the WinFileDlg() and WinFontDlg() functions.

File Dialog

The standard file dialog enables a user to specify a file to be opened or a file name under which current work is to be saved, including the ability to switch directories and logical drives. The file dialog provides basic capabilities, and is designed in such a way that it may be modified if additional function is required.

The file dialog is displayed using the WinFileDlg() function. The dialog may be displayed as either an "Open" dialog or a "Save as" dialog, depending upon the value of control flags specified in a FILEDLG structure passed as a parameter to the function call. The WinFileDlg() function is shown in Figure "Standard Dialogs - WinFileDlg() Function".

The appearance of the file dialog is controlled by the FDS_* style flags specified in the fl field in the FILEDLG structure. The fields in this structure are:

Field

cbSize fl IUser IReturn ISRC pszTitle pszOKButton pfnDlgProc pszIType pszITypeList pszIDrive ppszIDriveList hMod szFullFile ppszFQFilename IFQFCount idDlg x,y sEAType

For applications with specialized file handling requirements, the standard file dialog may be subclassed, allowing these requirements to be handled while retaining standard processing for the majority of events. This subclassing is invoked by specifying the address of an application-defined dialog procedure in the pfnDlgProc field in the FILEDLG structure, and by specifying the resource identifier of an application-defined dialog template if controls are to be added or removed from the dialog.

Note that application-defined dialog procedures should invoke the WinFileDlgProc() function as their default case for message processing, to ensure that messages not explicitly processed by the application are passed to the standard file dialog procedure for correct default processing.

Font Dialog

The standard font dialog enables a user to specify a choice of font names, styles, and sizes from the range available within a given application. The font dialog is intended to fit basic application needs, and is designed in such a way that additional function may be added by subclassing the dialog procedure.

The font dialog is displayed using the WinFontDlg() function, specifying the owner window for the dialog box, and a FONTDLG control structure. The use of the WinFontDlg() function is shown in Figure "WinFontDlg() Function - Sample Code".

The appearance of the dialog is determined by the FNTS_* flags specified in the fl field of the FONTDLG structure, and by the other fields in this structure. The fields in the FONTDLG structure are:

Field

cbSize hpsScreen hpsPrinter pszTitle pszPreview pszPtSizeList pfnDlgProc szFamilyname fxPointSize fl flFlags flType flTypeMask flStyle flStyleMask flCHSOptions flCHSMask clrFore clrBack lUser lReturn ISRC lEmHeight IXHeight iExternalLeading fAttrs sNominalPointSize usWeight usWidth x,y idDlg hmod

Applications may customize the font dialog through subclassing, by specifying the FNTS_CUSTOM style flag, giving the resource identifier and module handle of the application's customized font dialog template, and the address of an application-defined dialog procedure, in the FONTDLG structure. The WinFontDlg() function then performs the subclassing operation on the application's behalf.

Note that application-defined dialog procedures should invoke the WinFontDlgProc() function as their default case for message processing, to ensure that messages not explicitly processed by the application are passed to the standard font dialog procedure for correct default processing.

An application that uses its own dialog template must include all of the standard controls within the dialog box, in addition to its own customized controls. Those controls, which are not required, may be rendered invisible in order to provide the correct appearance.

Control window identifiers in the range 0x0000 to 0x0FFF are reserved for use by standard controls. The application's own controls should therefore use window identifiers greater than 0x0FFF.


[Back: Modal Action Windows]
[Next: Use of Control Windows]