Microsoft Foundation Classes (mfc.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
CDialog::Create
◄CDialog► ◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
BOOL Create( const char FAR* lpTemplateName, CWnd* pParentWnd = NULL );
BOOL Create( UINT nIDTemplate, CWnd* pParentWnd = NULL );
Parameter Description
<lpTemplateName> Contains a null-terminated string that is the name of a
dialog-box resource template.
<pParentWnd> Points to the parent 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, as shown in the following code:
if( pParentWnd == NULL )
pParentWnd = AfxGetApp()->m_pMainWnd;
<nIDTemplate> Contains the ID number of a dialog-box resource
template.
Remarks
Call Create when you construct your dialog-box object. You can put the
call to create inside the constructor or call it after the constructor
executes.
Two forms of the Create member function are provided for access to the
dialog template resource either by template name or by template ID
number.
For either form, you also pass a pointer to the parent window object. If
you don't, the dialog will be created with its parent window set to the
main application window. Modeless dialogs can use this pointer to send
messages to the parent if needed.
Before the dialog box is displayed, Windows sends the ◄WM_INITDIALOG►
message to the dialog box. If the dialog box has the DS_SETFONT style,
Windows also sends the ◄WM_SETFONT► message before the control windows
are created. You can override the ◄OnInitDialog► and ◄OnSetFont► member
functions to provide special handling of these messages.
The Create member function returns immediately after it creates the
dialog box.
Use the WS_VISIBLE style in the dialog template if the dialog box should
appear when the parent window is created. You can also specify other
dialog styles in the template as explained in the Windows Software
Development Kit documentation. These include styles that specify:
■ The frame around the dialog box.
■ Whether the dialog window is a pop-up or child window.
■ Whether the dialog box has a border or a Control menu.
■ How controls are to be grouped and the tabbing order between them.
Use the CWnd::DestroyWindow function to destroy a dialog box created by
the Create function.
A dialog box can contain up to 255 controls.
Return Value
Both forms return TRUE if dialog creation and initialization was
successful; otherwise FALSE.
See Also
◄CWnd::DestroyWindow►, ◄CDialog::CreateIndirect►, ◄::CreateDialog►,
◄WM_SETFONT►, ◄WM_INITDIALOG►
-♦-