Using Private Templates with Common Dialogs

Last reviewed: November 2, 1995
Article ID: Q74609
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) version 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT version 3.5
    

SUMMARY

An application which 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.


Additional reference words: 3.10 3.50
KBCategory: kbui
KBSubcategory: UsrCmnDlg


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.