Changing Property Sheets to Wizards
Here's a piece of information that surprises most people: A wizard is just a specialproperty sheet. Instead of tabbed pages on each sheet that allow users to fill in the
information in any order or to skip certain pages entirely, a wizard has Back, Next, and
Finish buttons to move users through a process in a certain order. This forced sequence
makes wizards terrific for guiding your application's users through the steps needed to
complete a complex task. You've already seen how AppWizard in Visual C++ makes it easy
to start a new project. You can create your own wizards suited to whatever application
you want to build. In the following sections, you'll see how easy it is to convert a
property sheet to a wizard.
Running the Wizard Demo Application
To understand Wizards, this section will show you the Wizard Demo application, which
is built in much the same way as the Property Sheet Demo application that you created
earlier in this chapter. This chapter won't present step-by-step instructions to build
Wizard Demo. You will be able to build it yourself if you want, using the general steps
presented earlier and the code snippets shown here.
When you run the Wizard Demo application, the main window appears, looking very
much like the Property Sheet Demo main window. The File menu now includes a Wizard
item; choosing File Wizard brings up the wizard shown in Figure 12.17.
FIG. 12.17 The Wizard Demo application displays a wizard rather than a property sheet.
The wizard isn't too fancy, but it does demonstrate what you need to know to program
more complex wizards. As you can see, this wizard has three pages. On the first page is an
edit control and three buttons: Back, Next, and Cancel. The Back button is disabled
because there is no previous page to go back to. The Cancel button enables users to
dismiss the wizard at any time, canceling whatever process the wizard was guiding users
through. The Next button causes the next page in the wizard to appear.
You can change whatever is displayed in the edit control if you like. However, the
magic really starts when you click the Next button, which displays Page 2 of the wizard
(see Figure 12.18). Page 2 contains a check box and the Back, Next, and Cancel buttons.
Now the Back button is enabled, so you can return to Page 1 if you want to. Go ahead
and click the Back button. The wizard tells you that the check box must be checked (see
Figure 12.19). As you'll soon see, this feature of a wizard enables you to verify the
contents of a specific page before allowing users to advance to another step.
FIG. 12.18 In Page 2 of the wizard, the Back button is enabled.
After checking the check box, you can click the Back button to move back to Page 1 or
click Next to advance to Page 3. Assuming that you advance to Page 3, you see the
display shown in Figure 12.20. Here, the Next button has changed to the Finish button
because you are on the wizard's last page. If you click the Finish button, the wizard
disappears.
FIG. 12.19 You must select the check box before the wizard will let you leave Page 2.
FIG. 12.20 This is the last page of the Wizard Demo Application's wizard.
No comments:
Post a Comment