developer's mag
main page
article
part 1
part 2
part 3
part 4
part 5
part 6
|
5 - Show() and Hide()
Another way of working with a dialog is with the Show()
and Hide() functions. These functions make use of an
already-created window. The sequence of action would be:
- The dialog is created, and exists in a hidden state,
which simply involves setting the hidden flag in the
constructor.
- When the program wishes to display the dialog, it
calls dialog->Show() At this point, control goes
to the visible dialog, much as if you had called it
with GUI_EventLoop().
- When the dialog is done, it calls Hide().
- The dialog's data can continue to be accessed from
the object, since it has not been deleted.
- Eventually, the dialog is destroyed before the
program ends.
The biggest advantages of this method are that the
dialog can be created in advance (useful for detailed
or graphical dialogs), and the data in the dialog is
always available. However, synchronizing the dialog to
the main window is problematic - the Show() call returns
immediately, and so the calling window has no easy way to
identify when the dialog disappears or closes. As well,
you have to hide the close button, since if the window
is closed, object memory is freed, and Show() will fail
next time. For these reasons, you might want to avoid
Show() and Hide() in favor of GUI_EventLoop().
Previous Section
Next Section
|