INF: Using Private Templates with Common Dialogs

ID Number: Q74609

3.10

WINDOWS

Summary:

An application using the common dialog dynamic-link library (DLL) can

provide its own dialog resource template for the DLL to use 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 DLL'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 the Print Dialog 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.