MFC modal dialog prevent another modal dialog to continue after dialog closed

139 Views Asked by At

Created a simple mfc project, then create three dialog and add CDialog class.

TestA, TestB, TestC classes.

In the main frame dialog,

void CMFCApplication3Dlg::OnBnClickedButton1() {
  TestA *a = new TestA(CWnd::FromHandle(GetSafeHwnd()));
  a->Create(TestA::IDD, CWnd::FromHandle(GetSafeHwnd()));
  a->ShowWindow(SW_SHOW);
}

void CMFCApplication3Dlg::OnBnClickedButton2() {
  TestB b;
  b.DoModal();
  AfxMessageBox(L"B closed");
}

Class TestA has,

void TestA::OnBnClickedButton1() {
  TestC c;
  c.DoModal();
  AfxMessageBox(L"C closed");
}

The problem is occur when

  1. Open TestA
  2. Open TestB
  3. Open TestC

Now when i close TestB the AfxMessageBox(L"B closed"); is not run until i close TestC dialog.

Why is this happen?

0

There are 0 best solutions below