HOWTO: Use Private Templates with Common Dialogs

ID: Q74609


The information in this article applies to:


SUMMARY

An application that uses the common dialog library (COMMDLG.DLL) can provide its own dialog resource template to be used instead of the standard template. In this way, the application can include private dialog items specific to its needs without losing the benefits of using the COMMDLG's dialog handling.


MORE INFORMATION

Each common dialog data structure contains an lpTemplateName element. (Note that the Print Dialog structure contains two such elements, each with a distinct name -- see specifics of PrintDlg for details.) This element points to a null-terminated string that names the dialog box template resource to be substituted for the standard dialog template. If the dialog resource is numbered, the application can use the MAKEINTRESOURCE macro to convert the number into a pointer to a string. Alternatively, the application can choose to pass a handle to a preloaded dialog template. The Flags element of the dialog data structure must be set to indicate which method is being used.

After loading the application's dialog template, the common dialog DLL initializes the dialog items as it would for the standard template. This leads to an important point: all dialog items in the standard template must also exist in the application's private template. Note that the items do not have to be enabled or visible -- they just have to exist.

Once the DLL has finished handling the WM_INITDIALOG message, it passes that message on to the application's dialog hook function. The hook function handles WM_INITDIALOG by initializing the application's private dialog items. It can also disable and hide any items from the standard template that the application does not want to use.

The hook function should process messages and notifications concerning the private dialog items.


Keywords          : kbCmnDlg kbNTOS310 kbNTOS350 kbNTOS351 kbGrpUser kbWinOS310 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: March 7, 1999