OFNHookProcOldStyle callback function (Windows)

Switch View :
ScriptFree
OFNHookProcOldStyle callback function

[Starting with Windows Vista, the Open and Save As common dialog boxes have been superseded by the Common Item Dialog. We recommended that you use the Common Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]

Applies to: desktop apps only

Receives messages or notifications intended for the dialog box procedure. The OFNHookProcOldStyle hook procedure is an application-defined or library-defined callback function that is used with the Open and Save As dialog boxes.

Syntax

UINT_PTR CALLBACK OFNHookProcOldStyle(
  __in  HWND hdlg,
  __in  UINT uiMsg,
  __in  WPARAM wParam,
  __in  LPARAM lParam
);

Parameters

hdlg [in]

A handle to the Open or Save As dialog box for which the message is intended.

uiMsg [in]

The identifier of the message being received.

wParam [in]

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

lParam [in]

Additional information about the message. The exact meaning depends on the value of the uiMsg parameter. If the uiMsg parameter indicates the WM_INITDIALOG message, lParam is a pointer to an OPENFILENAME structure containing the values specified when the dialog box was created.

Return value

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.

Remarks

If you specify the OFN_EXPLORER flag when you create an Open or Save As dialog box, and you want a hook procedure, you must use an Explorer-style OFNHookProc hook procedure.

When you use the GetOpenFileName or GetSaveFileName functions to create an old-style Open or Save As dialog box, you can provide an OFNHookProcOldStyle hook procedure. To enable the hook procedure, use the OPENFILENAME 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.

The default dialog box procedure processes the WM_INITDIALOG message before passing it to the hook procedure. For 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.

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

Do not call the EndDialog function from the hook procedure. Instead, the hook procedure can call the PostMessage 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.

You can subclass the standard controls of a common dialog box. However, the dialog box procedure may also subclass the controls. Because of this, you should subclass controls when your hook procedure processes the WM_INITDIALOG message. This ensures that your subclass procedure receives the control-specific messages before the subclass procedure set by the dialog box procedure.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Commdlg.h (include Windows.h)

See also

Reference
GetOpenFileName
GetSaveFileName
OFNHookProc
OPENFILENAME
WM_INITDIALOG
Conceptual
Common Dialog Box Library

 

 

Send comments about this topic to Microsoft

Build date: 2/10/2012

Community Content

Harish_621
Problem with file having extension more then 3 charactor
I write a program for GetOpenFileNAme() dailog box with 'OFNHookProcOldStyle callback function '. but it does not work properly. When user enter extension '*.xls' still the dailog box show *.xlsx' files. This happens only with OLD common dailog box. with Explorer style dailog box shows correctly.