Tabs and Wizards

Here's a pair of related questions:

Dear Dr. GUI:

Does Visual C++/MFC, or some other easily available resource, provide a convenient way to generate tabbed dialog boxes, such as those commonly used in most of Microsoft's newer programs?

The Baxter Family

...and...

How do you implement wizards in your applications? Are there APIs or any other method employed by Microsoft that is available to developers in general?

Israel Frankel

Dr. GUI replies:

Didn't know Windows programming was a family activity! Cool!

These questions are related (cousins, perhaps) because to implement either tabbed dialog boxes or wizards you'll derive classes from the same MFC classes: CPropertySheet and CPropertyPage.

The property sheet is the "container" for all the property pages. Each property page (tabbed page or wizard page) has a separate class. Associated with each property page class is a dialog box template that specifies the controls on that page.

Tabbed dialog boxes are implemented as property sheets with tabs for selecting the property pages. Wizards are implemented as property sheets with "Back" and "Next" buttons for selecting the property pages. (A call to SetWizardMode tells MFC to handle the property sheet as a wizard rather than as a tabbed dialog box.) There's a great article about creating property sheets—entitled, oddly enough, "Property Sheets"—in the MSDN Library and in the Visual C++ document set. The documentation on CPropertySheet and CPropertyPage is helpful, as are the KnowledgeBase articles you'll find in the MSDN Library. (If you want the Win32 SDK way to do it, check out the article "We're Off to See the Wizard.")

In addition, starting with version 4.0, Visual C++ has a super-cool component in its Component Gallery (choose "Component" from the "Insert" menu), which allows you to easily add the framework for a property sheet (either modal or modeless) or wizard. When you select it, it invokes its own Property Sheet Wizard, which guides you through the process of creating the framework. (You still have to fill in the dialog box templates and get data in and out of the property pages, though, and you have to handle the logic for the Back/Next/Finish buttons. Wizards can't do everything for you.)

While you're at it, call up the Component Gallery to check out the other cool components and OLE (ActiveX) controls provided with Visual C++.