

Don't call the base class CDialog::OnCancel, because it calls EndDialog, which will make the dialog box invisible but will When you implement a modeless dialog box, always override the OnCancel member function and call DestroyWindow from within it. IDD_DIALOG_TEST is the resource ID of the dialog box.Ĥ.2 There is an important advise for the CDialog-based classes of modeless dialogs (see M_dialog_test.Create(IDD_DIALOG_TEST, this) Void CTestMFC01Dlg::OnBnClickedButtonInvokeModelessTestDialog()

:Ĥ.1 Then in your button handler, you call the CDialog::Create() and CDialog::ShowWindow() methods on the CDialogTest member : To display a modeless dialog box, you would first need to define a member of type CDialogTest for your main dialog class (the one that the MFC wizard created for you), e.g. TODO: Add your control notification handler code hereĤ. Void CTestMFC01Dlg::OnBnClickedButtonInvokeModalTestDialog() To display a modal dialog box, you can use the following code for your button handler : (VS.80).aspx for more explanation on the difference between them).ģ. Next thing you need to do is to decide whether you want to start up a modal or a modeless dialog box (see I assume that you have already defined a CDialog-based class to represent the new dialog resource that you have created.
