This documentation is archived and is not being maintained.


Call this member function to create a modeless dialog box from a dialog-box template in memory.

virtual BOOL CreateIndirect(
   LPCDLGTEMPLATE lpDialogTemplate,
   CWnd* pParentWnd = NULL,
   void* lpDialogInit = NULL
virtual BOOL CreateIndirect(
   HGLOBAL hDialogTemplate,
   CWnd* pParentWnd = NULL


Points to memory that contains a dialog-box template used to create the dialog box. This template is in the form of a DLGTEMPLATE structure and control information, as described in the Platform SDK.
Points to the dialog object's parent window object (of type CWnd). If it is NULL, the dialog object's parent window is set to the main application window.
Points to a DLGINIT resource.
Contains a handle to global memory containing a dialog-box template. This template is in the form of a DLGTEMPLATE structure and data for each control in the dialog box.

Return Value

Nonzero if the dialog box was created and initialized successfully; otherwise 0.


The CreateIndirect member function returns immediately after it creates the dialog box.

Use the WS_VISIBLE style in the dialog-box template if the dialog box should appear when the parent window is created. Otherwise, you must call ShowWindow to cause it to appear. For more information on how you can specify other dialog-box styles in the template, see the DLGTEMPLATE structure in the Platform SDK.

Use the CWnd::DestroyWindow function to destroy a dialog box created by the CreateIndirect function.

Dialog boxes that contain ActiveX controls require additional information provided in a DLGINIT resource. For more information, see Knowledge Base article Q231591, " HOWTO: Use a Dialog Template to Create a MFC Dialog with an ActiveX Control." Knowledge Base articles are available in the MSDN Library Visual Studio documentation or at

See Also

CDialog Overview | Class Members | Hierarchy Chart | CDialog::CDialog | CWnd::DestroyWindow | CDialog::Create | CreateDialogIndirect