A dialog box is a window with a title bar and sometimes a system menu, which can be moved around the screen. It can contain controls and other windows and is often used to allow the user to make some choice or to answer a question.
Dialogs can be made scrollable, automatically, for computers with low resolution screens: please see overview_dialog_autoscrolling for further details.
Dialogs usually contain either a single button allowing to close the dialog or two buttons, one accepting the changes and the other one discarding them (such button, if present, is automatically activated if the user presses the "Esc" key). By default, buttons with the standard wxID_OK and wxID_CANCEL identifiers behave as expected. Starting with wxWidgets 2.7 it is also possible to use a button with a different identifier instead, see
Also notice that the
Modal and Modeless
There are two kinds of dialog, modal and modeless. A modal dialog blocks program flow and user input on other windows until it is dismissed, whereas a modeless dialog behaves more like a frame in that program flow continues, and input in other windows is still possible. To show a modal dialog you should use the
Note that the modal dialog is one of the very few examples of wxWindow-derived objects which may be created on the stack and not on the heap. In other words, while most windows would be created like this:
You can achieve the same result with dialogs by using simpler code:
An application can define a
Styles
This class supports the following styles:
See:
This class is derived (and can use functions) from:
wxWidgets docs:
Event types emitted from this class:
Default constructor.
Constructor.
See:
Destructor.
Deletes any child windows before deleting the physical window.
See overview_windowdeletion for more info.
Used for two-step dialog box construction.
See:
Creates a sizer with standard buttons.
The sizer lays out the buttons in a manner appropriate to the platform.
This function uses
Creates a
The sizer lays out the buttons in a manner appropriate to the platform.
Ends a modal dialog, passing a value to be returned from the
See:
Gets the identifier of the button which works like standard OK button in this dialog.
See:
Gets the return code for this window.
Remark: A return code is normally associated with a modal dialog, where
See:
Returns true if the dialog box is modal, false otherwise.
Sets the identifier to be used as OK button.
When the button with this identifier is pressed, the dialog calls
Also, when the user presses a hardware OK button on the devices having one or the special OK button in the PocketPC title bar, an event with this id is generated.
By default, the affirmative id is wxID_OK.
See:
Sets the return code for this window.
A return code is normally associated with a modal dialog, where
See:
Hides or shows the dialog.
The preferred way of dismissing a modal dialog is to use
Shows an application-modal dialog.
Program flow does not return until the dialog has been dismissed with
Notice that it is possible to call
Note that this function creates a temporary event loop which takes precedence over the application's main event loop (see
Return: The value set with
See: