Implementing a dialog box using ATL Object Wizard

There are two ways to add a dialog box. If you are developing an ATL/COM dll then you can use ATL Object Wizard to add a dialog. Here are the steps:

Step 1: Go to Insert ATL Object, Select Category - Miscellaneous and double click on Dialog.

Step 2: Insert MyDlg as Short Name. And click Ok.

This wizard adds a class CMyDlg into your project. This class is derived from CAxDialogImpl. 

class CMyDlg : public CAxDialogImpl  

This class has OnInitDialog and handlers for Ok and Cancel buttons. You can modify this dialog according to your needs.

Now you can create this dialog box modal or modeless. For modal dialog box :

#include "mydlg.h" 

CMyDlg dlg; 

Dlg.DoModal();

 

for Modeless, call Create member function.

#include "mydlg.h" 

CMyDlg dlg; 

Dlg.Create( ::GetDestopWindow()); 

dlg.ShowWindow( SW_SHOWNORMAL);