OFNHookProc  JAX4EC 

An OFNHookProc hook procedure is an application-defined or library-defined callback procedure that is used with the Explorer-style Open and Save As common dialog boxes. The hook procedure receives notification messages sent from the common dialog box. The hook procedure also receives messages for any additional controls that you defined by specifying a child dialog template.

If you do not specify the OFN_EXPLORER flag when you create an Open or Save As common dialog box, and you want a hook procedure, you must use an old-style OFNHookProcOldStyle4_I3_.9 hook procedure. In this case, the dialog box will have the old-style user interface.

UINT APIENTRY OFNHookProc(

    HWND hdlg,

// handle to child dialog window

    UINT uiMsg,

// message identifier

    WPARAM wParam,

// message parameter

    LPARAM lParam

// message parameter

   );

 

 

Parameters

hdlg

Handle to the child dialog box of the Open or Save As dialog box. Use the GetParentR3JU_J function to get the handle to the Open or Save As dialog box window.

uiMsg

Identifies the message being received.

wParam

Specifies additional information about the message. The exact meaning depends on the value of the uiMsg parameter.

lParam

Specifies additional information about the message. The exact meaning depends on the value of the uiMsg parameter.

If the uiMsg parameter indicates the WM_INITDIALOGII1W.B message, lParam is a pointer to an OPENFILENAME2WIVNAE structure containing the values specified when the dialog box was created.

 

Return Values

If the hook procedure returns zero, the default dialog box procedure processes the message.

If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message.

For the CDN_SHAREVIOLATIONJNZA8F and CDN_FILEOKYH4I0E notification messages, the hook procedure should return a nonzero value to indicate that it has used the SetWindowLongD2OKIR function to set a nonzero DWL_MSGRESULT value.

Remarks

When you use the GetOpenFileNameFZGRJG or GetSaveFileName182.5BE functions to create an Explorer-style Open or Save As common dialog box, you can provide an OFNHookProc hook procedure. To enable the hook procedure, use the OPENFILENAME2WIVNAE structure that you passed to the dialog creation function. Specify the pointer to the hook procedure in the lpfnHook member and specify the OFN_ENABLEHOOK flag in the Flags member.

If you provide a hook procedure for an Explorer-style common dialog box, the system creates a dialog box that is a child of the default dialog box. The hook procedure acts as the dialog procedure for the child dialog. This child dialog is based on the template you specified in the OPENFILENAME structure, or it is a default child dialog if no template is specified. The child dialog is created when the default dialog procedure is processing its WM_INITDIALOGII1W.B message. After the child dialog processes its own WM_INITDIALOG message, the default dialog procedure moves the standard controls, if necessary, to make room for any additional controls of the child dialog. The system then sends the CDN_INITDONEY51ILY notification message to the hook procedure.

The hook procedure does not receive messages intended for the standard controls of the default dialog box. You can subclass the standard controls, but this is discouraged because it may make your application incompatible with future versions of the common dialog box. However, the Explorer-style common dialogs provide a set of messages that the hook procedure can use to monitor and control the dialog. These include a set of WM_NOTIFY1MZT7BR notification messages sent from the dialog, as well as messages that you can send to retrieve information from the dialog. For a complete list of these messages, see  Explorer-Style Hook Procedures265K7C5

If the hook procedure processes the WM_CTLCOLORDLGJYE6CZ message, it must return a valid brush handle for painting the background of the dialog box. In general, if it processes any WM_CTLCOLOR* message, it must return a valid brush handle for painting the background of the specified control.

Do not call the EndDialogNYK21C function from the hook procedure. Instead, the hook procedure can call the PostMessageFIXDT_ function to post a WM_COMMAND message with the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog box and causes the dialog box function to return FALSE. If you need to know why the hook procedure closed the dialog box, you must provide your own communication mechanism between the hook procedure and your application.

OFNHookProc is a placeholder for the application-defined or library-defined function name. The LPOFNHOOKPROC type is a pointer to either an OFNHookProc or OFNHookProcOldStyle hook procedure.

See Also

GetOpenFileName, GetSaveFileName, OFNHookProcOldStyle, OPENFILENAME