Adding a Hook Function to a Common Dialog BoxLast reviewed: November 2, 1995Article ID: Q86721 |
The information in this article applies to:
SUMMARYMany applications developed for the Microsoft Windows environment using dialog boxes from the common dialogs library (COMMDLG.DLL) require hook functions. A hook function for one of the common dialog boxes is similar to a subclass procedure for a standard Window control, such as an edit control. Through a hook function, an application can process all messages addressed to the dialog box. The text below discusses the steps required to implement a hook function with a common dialog box. A hook function is most often used in conjunction with a custom dialog template. For details using a custom dialog template with one of the common dialog boxes, query on the following words in the Microsoft Knowledge Base:
steps add custom template MORE INFORMATIONThe hook function receives all messages addressed to a common dialog box. With the exception of the WM_INITDIALOG message, the hook function receives messages before its associated common dialog box does. If the hook function processes a message completely, it returns TRUE. If the common dialog box must provide default processing for a message, the hook function returns FALSE. CDDEMO, one of the advanced sample applications provided with version 3.1 of the Microsoft Windows Software Development Kit (SDK), demonstrates adding a hook function to the File Open dialog box. The eight steps involved in this process are as follows:
BOOL FAR PASCAL MyHookProc(HWND hDlg, unsigned message, WORD wParam, LONG lParam) { switch (message) { case WM_INITDIALOG: OutputDebugString("Hello hook function!"); return TRUE; case WM_COMMAND: switch(wParam) { case IDD_MYNEWCONTROL: // Perform appropriate processing here... return TRUE; default: break; } break; default: break; } return FALSE; } |
Additional reference words: 3.10 3.50 3.51 4.00 95
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |