Hook Procedures for Common Dialog Boxes

For each of the common dialog boxes, you can enable a hook procedure to process messages from the default dialog box procedure. There are two general types of common dialog hook procedures:

·The standard hook procedure used with most common dialog boxes

·The Explorer-style hook procedure supported by the Open and Save As dialog boxes

When you provide a standard hook procedure for one of the common dialog boxes, the default dialog box procedure handles its messages as follows.

Message Handling
WM_INITDIALOG The default dialog box procedure processes the message before passing it to the hook procedure. The message's lParam parameter is a pointer to the initialization structure specified when the dialog was created.
All other messages The hook procedure receives the message first. Then, the return value of the hook procedure determines whether the default dialog procedure processes the message or ignores it.

For the Explorer-style Open and Save As dialog boxes, the hook procedure does not receive messages intended for the standard controls in the common dialog box. Instead, it receives notification messages from the dialog box and messages for any additional controls that you defined in a custom template. For more information, see Explorer-Style Hook Procedures.

To enable a hook procedure, set an ENABLEHOOK value in the Flags member of the corresponding structure for the dialog box. If an ENABLEHOOK flag is set, an lpfnHook member of the structure must specify the address of the hook procedure.

The following table shows the type of hook procedure to provide for each of the common dialog boxes.

Common dialog box type Hook procedure
Color CCHookProc
Find or Replace FRHookProc
Font CFHookProc
Open or Save As
(Explorer-style)
OFNHookProc
Open or Save As
(Old-style)
OFNHookProcOldStyle
Print PrintHookProc
Page Setup PageSetupHook

For the Page Setup dialog box, you can also specify a PagePaintHook hook procedure. This is a special hook procedure that you can use to customize the appearance of the sample page displayed by the Page Setup dialog box.

Note The Print Setup dialog box has been superseded by the Page Setup dialog box, which should be used by new applications written for Windows 95 or for Windows NT versions 3.51 or later. However, for compatibility with earlier versions of Windows, the PrintDlg function continues to support display of the Print Setup dialog box. You can provide a SetupHookProc hook procedure for the Print Setup dialog box.