I create a window with CreateWindow()
and show it with ShowWindow()
. But the parent window on which this was created should be disabled until user returns from this window, i.e. it should simulate modal dialog box.
You create a modal dialog box by using the DialogBox function. You must specify the identifier or name of a dialog box template resource and a pointer to the dialog box procedure. The DialogBox function loads the template, displays the dialog box, and processes all user input until the user closes the dialog box.
To create a modeless dialog box, call your public constructor and then call the dialog object's Create member function to load the dialog resource. You can call Create either during or after the constructor call. If the dialog resource has the property WS_VISIBLE, the dialog box appears immediately.
Modal dialog boxes, which require the user to respond before continuing the program. Modeless dialog boxes, which stay on the screen and are available for use at any time but permit other user activities.
A dialog box is a temporary window an application creates to retrieve user input. An application typically uses dialog boxes to prompt the user for additional information for menu items.
Make sure you set the hwndParent
in CreateWindow
and use EnableWindow(hwndParent, FALSE)
to disable the parent after showing the pop up window. Then enable the parent with EnableWindow(hwndParent, TRUE)
after the pop up window has been closed.
Modality, part 1: UI-modality vs code-modality explains how to do this, and why you might not want to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With