CSimpleDialog Class


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CSimpleDialog Class.

This class implements a basic modal dialog box.

template <WORD t_wDlgTemplateID, BOOL t_bCenter = TRUE>  
class CSimpleDialog : public CDialogImplBase



The resource ID of the dialog template resource.

TRUE if the dialog object is to be centered on the owner window; otherwise FALSE.

Public Methods

CSimpleDialog::DoModalCreates a modal dialog box.

Implements a modal dialog box with basic functionality. CSimpleDialog provides support for Windows common controls only. To create and display a modal dialog box, create an instance of this class, providing the name of an existing resource template for the dialog box. The dialog box object closes when the user clicks any control with a pre-defined value (such as IDOK or IDCANCEL).

CSimpleDialog allows you to create only modal dialog boxes. CSimpleDialog provides the dialog box procedure, which uses the default message map to direct messages to the appropriate handlers.

See Implementing a Dialog Box for more information.



Header: atlwin.h

Invokes a modal dialog box and returns the dialog-box result when done.

INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow());


A handle to the parent of the dialog box. If no value is provided, the parent is set to the current active window.

Return Value

If successful, the return value is the resource ID of the control that dismissed the dialog box.

If the function fails, the return value is –1. To get extended error information, call GetLastError.


This method handles all interaction with the user while the dialog box is active. This is what makes the dialog box modal; that is, the user cannot interact with other windows until the dialog box is closed.

Class Overview