Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a win32 modal window with CreateWindow

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.

like image 296
cagribal Avatar asked Apr 09 '09 15:04

cagribal


People also ask

How do I create a dialog box in win32?

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.

How do you make a modeless 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.

What's the difference between modal and modeless forms?

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.

What is Windows DialogBox?

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.


2 Answers

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.

like image 56
Maurice Flanagan Avatar answered Sep 22 '22 16:09

Maurice Flanagan


Modality, part 1: UI-modality vs code-modality explains how to do this, and why you might not want to.

like image 35
jeffm Avatar answered Sep 25 '22 16:09

jeffm