c++mfcdialogmodal-dialogsdi

Modal dialog becomes non-modal


I have MFC SDI application, in it modal dialog is displayed. During that second dialog can be displayed, which is also modal. Second dialog is doing some job and auto-closed by

dlg->PostMessage(WM_CLOSE);

All that works but after second dialog is closed first dialog is not modal any more, this means I can click the main window of the application.

Any ideas how this can be solved?


Solution

  • A window can only handle one modal dialog at a time.

    Therefore, specify the first dialog as parent for the second.