다음을 통해 공유


CDialog::InitModalIndirect

Call this member function to initialize a modal dialog object using a dialog-box template that you construct in memory.

BOOL InitModalIndirect(
   LPCDLGTEMPLATE lpDialogTemplate,
   CWnd* pParentWnd = NULL,
   void* lpDialogInit = NULL
);
   BOOL InitModalIndirect(
   HGLOBAL hDialogTemplate,
   CWnd* pParentWnd = NULL
);

Parameters

  • lpDialogTemplate
    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 Windows SDK.

  • hDialogTemplate
    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.

  • pParentWnd
    Points to the parent or owner window object (of type CWnd) to which the dialog object belongs. If it is NULL, the dialog object's parent window is set to the main application window.

  • lpDialogInit
    Points to a DLGINIT resource.

Return Value

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

Remarks

To create a modal dialog box indirectly, first allocate a global block of memory and fill it with the dialog box template. Then call the empty CDialog constructor to construct the dialog-box object. Next, call InitModalIndirect to store your handle to the in-memory dialog-box template. The Windows dialog box is created and displayed later, when the DoModal member function is called.

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 https://support.microsoft.com.

Requirements

Header: afxwin.h

See Also

Concepts

CDialog Class

CDialog Members

Hierarchy Chart

DialogBoxIndirect

CDialog::DoModal

CWnd::DestroyWindow

CDialog::CDialog