Skip to content
Search

CDialog

lastmod 2021-02-26created 2021-02-262 edits

Describes how to create a dialog.

Types of dialogs

There are two types of dialogs, as follows.

Modal dialog.
While the dialog is displayed, it monopolizes all control of the program, so no other work can be done until the dialog is closed.
Modaless dialog.
Even while the dialog is displayed, it does not monopolize control of the program, so you can push the dialog aside for a moment and do other work.

-

Modal

Modaless

Creation

CDialog::DoModal()

CDialog::Create()

Destruction

CDialog::EndDialog() (available in the dialog implementation class.)

CWnd::DestroyWindow()

Instance declaration

Stack (local variable), heap (dynamic allocation)

Heap (dynamic allocation)

Sample

CModalDlg dlg;
dlg.~DoModal();
CModalessDlg * dlg = new CModalessDlg;
dlg->Create();
dlg->~ShowWindow(~SW_SHOW);
dlg->~DestoryWnd();
delete dlg;

Checking the status of a modaless dialog

You can check the status of the dialog with the methods below.

Return value

CWnd::IsWindowEnabled()

CWnd::IsWindowVisible()

TRUE

The dialog is ready to use.

The dialog is actually visible.

FALSE

The dialog is not ready to use.

The dialog is not visible.

See also

Favorite site

author Zer0 sitemap