1

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?

tatarmiki
  • 11
  • 1
  • Please provide a [mcve]. It appears like you do not understand [modal and modeless dialogs](https://learn.microsoft.com/en-us/cpp/mfc/modal-and-modeless-dialog-boxes) well enough to use them proficiently, and it is unclear from the question, what you are ultimately trying to accomplish. – IInspectable Nov 13 '18 at 12:41
  • probably because `c.DoModal();` doesn't return until the TestC dialog is closed, so the program waits at that point – Edward Clements Nov 13 '18 at 17:30
  • At least to me it is totally unclear what you mean with "Open TestA, Open TestB, Open Test C". TestB is opened as a modal dialog, so TestA should not see any "OnBnClickedButton1" and TestC should not open!? – Werner Henze Nov 22 '18 at 09:56

0 Answers0