2

I'm trying to run two windows in MFC in the same time - when i run my app. In BOOL CrTestTaskApp::InitInstance() - init function of my app i wrote this:

CrStartDlg sDlg;
sDlg.DoModal();
CrMainDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();

if (nResponse == IDOK)
{

}
else if (nResponse == IDCANCEL)
{

}

But second dialog apears only after i closed first. And also, if i make Modal() second dialog on BtnClick() first dialog - i cant switch between them.. Active only one...

Help me pls.

user2706838
  • 1,061
  • 2
  • 13
  • 21
  • 1
    You cannot have 2 Modal dialogs open at the same time. If you want to have more than 1 dialog open, you have to use Modeless dialogs. – Zac Howland Aug 26 '13 at 14:45

1 Answers1

3

You need modeless dialogs, as opposed to modal created by DoModal method.

Modeless dialogs are created with CDialog::Create and act as regular windows, responding to messages dispatched via shared message queue/pump.

Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thanks, it helped me. Could you please tell if I could make already existing dialog modelless? – user2706838 Aug 26 '13 at 15:08
  • You might needs some minor updates there, esp. around `EndDialog` calls which are not applicable to modeless dialogs. Most of message handlers should be fine. – Roman R. Aug 26 '13 at 15:39