Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 15: Fundamental Controls


}


  1. Test the application


15.5.2..Wizard Buttons....................................................................................


Like a property sheet, a wizard can be made of one or more pages (it is possible but not
practical to have a wizard with only one page). A wizard you have just created may have
the Back, Next, Cancel, and Help buttons:

To exploit it, the user would click a Next or Back buttons. The Next button allows the
user to access the page that succeeds the current one. The Back button implements the
opposite, allowing the user to access the previous page. If the wizard is equipped with a
Cancel button, the user can close and dismiss it at any time. This, by default allows you
to ignore anything the user did on the wizard.

As with anything else in the world or programming, you should make your wizard
intuitive and friendly. For example, on the first page, since there is no reason for the user
to access the previous page, you should disable it. On the other hand, when the user gets
to the last page, since there is no succeeding page, there is no need for a Next button.
Consequently, you should replace it with a Finish button. Fortunately, the display of these
buttons is not the most difficult thing to manage on a wizard.

In order to decide what button(s) should be available when a particular page is accessed,
generate its CPropertyPage::OnSetActive() event. Its syntax is:

virtual BOOL OnSetActive( );

This event fires when a page of your choice is accessed, allowing you to do what you
want on the wizard page. One of the actions you can take when a page displays is to
decide what button(s) should be displayed on the wizard. The buttons of a wizard are
managed through the CPropertySheet::SetWizardButtons() method. Its syntax is:
Free download pdf