Expand Minimize
3 out of 4 rated this helpful - Rate this topic
 

Part 8



Dialog Boxes and Property Sheets

In the real world, most controls appear not in top-level windows but in dialog boxes. A dialog box, also known as a dialog, is a window that pops up to solicit input from the user. The window that appears when you select Open from an application's File menu is one example of a dialog box; the window that pops up when you select File-Print is another. Dialog boxes are simpler to create than ordinary windows because a few statements in an RC file are sufficient to define a dialog box and all the controls it contains.

Dialog boxes come in two basic varieties: modal and modeless. A modal dialog box disables the window to which it is assigned�its owner�until the dialog box is dismissed. It's an application's way of saying, "I can't do anything else until you supply me with the input I need." A modeless dialog box behaves more like a conventional window. Its owner can be reactivated even while the dialog box is displayed.

MFC encapsulates the functionality of both modal and modeless dialog boxes in the class named CDialog. Dialog box programming is relatively easy when you use the Microsoft Windows SDK, but it's even easier with MFC. You can often build even complex dialog boxes with just a few lines of code, which speeds program development and reduces the likelihood of errors. MFC also provides convenient C++ implementations of the Windows common dialogs�Open dialogs, Print dialogs, and other dialog boxes commonly found in Windows applications.

A close cousin of the dialog box is the property sheet. A property sheet is essentially a dialog box with tabbed pages. Property sheets are great for lending a higher level of organization to the controls in a dialog. They're also space-efficient, allowing more controls to fit in a finite amount of space, and they're fast becoming commonplace in Windows applications. MFC makes property sheet handling simple with its CPropertySheet and CPropertyPage classes. Take it from someone who's been there: if you've programmed property sheets without a class library, you'll appreciate the work MFC does to make dealing with property sheets fundamentally no different from�and no more difficult than�dealing with ordinary dialog boxes.

� 2013 Alex library. All rights reserved.