ebmDevMag.com home
ebm Developer's Magazine
links

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:
  1. The dialog is created, and exists in a hidden state, which simply involves setting the hidden flag in the constructor.
  2. 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().
  3. When the dialog is done, it calls Hide().
  4. The dialog's data can continue to be accessed from the object, since it has not been deleted.
  5. 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

Copyright © 2001-2006 ebmDevMag.com - Legal Notice