There is no real way
See : How can I tell whether a window is modal?
How to know a dialog is modal or modeless from windows handle?
Hi,
In a dll I have child dialog with button control. In main application I am using this child dialog from dll in modal dialog or modeless dialog. The parent of modal or modeless dialog is modal dialog.
When clicking button control in dll I need to launch modal dialog.
I want to prevent the user from dismissing/closing the super parent dialog(first), when both the parent dialog(second) and the last modal dialog(third) are open. To handle this I need to disable super parent dialog(first) before launching last modal dialog(third). I need to disable super parent dialog only if parent of last modal dialog is modeless.
How to check a dialog is modal or modeless from the handle?
2 answers
Sort by: Most helpful
-
Castorix31 86,316 Reputation points
2020-12-04T09:15:28.4+00:00 -
RLWA32 46,111 Reputation points
2020-12-04T12:41:36.1+00:00 Assuming that the question is speaking to the Windows API and not MFC -
When the modal first dialog creates the second dialog it can pass a parameter to indicate whether the second dialog is modal or modeless. If the second dialog is to be modal use DialogBoxParam to pass the parameter. If the second dialog is to be modeless, use CreateDialogParam to pass the parameter. The second dialog stores the value of the parameter when it handles its WM_INITDIALOG message.
The second dialog can then determine if it was created as modal or modeless. If modeless, it can disable its owner window before creating the third modal dialog and enable it when the third modal dialog returns.
In any event, the dialog procedure for a modal dialog should close the dialog using EndDialog while a modeless dialog would use DestroyWindow. So unless you are using the same dialog procedure for both modal and modeless dialogs, they would be specifically written for either modal or modeless operation.