class ScDlg : public CDialog
{....
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
}
And I made two classes based on ScDlg.
FirstDlg : ScDlg
SecondDlg : ScDlg
then I declare both two classes in App class like this.
FirstDlg dlg1;
m_pMainWnd = &dlg1;
INT_PTR nResponse1 = dlg1.DoModal();
if (nResponse1 == IDOK){ }
else if (nResponse1 == IDCANCEL){return false;}
SecondDlg dlg2;
m_pMainWnd = &dlg2;
INT_PTR nResponse2 = dlg2.DoModal();
if (nResponse2 == IDOK){ }
else if (nResponse2 == IDCANCEL){return false;}
First dlg perfectly works. When I pressed OK button,
it returns IDOK.
However, dlg2.DoModal() immediately returns -1.