Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 16: Text-Based Controls Visual C++ and MFC Fundamentals


void SetWizardButtons(DWORD dwFlags);

The dwFlags argument is a constant or a combination of values that defines the buttons to
display. The possible values are PSWIZB_BACK for the Back button, PSWIZB_NEXT
for the Next button, PSWIZB_FINISH for the Finish button, and
PSWIZB_DISABLEDFINISH to disable Finish button disabled.

On the first page, to display the Next button while disabling the Back button, you can
pass only the PSWIZB_NEXT value. On the last page, you should display the Back and
the Finish buttons. All pages between the first and the last should display the Back and
the Next buttons, unless you have a reason to do otherwise.

To add your own button to the wizard, you can use the same approach we saw earlier.
Here is an example:

CmyWizardSheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();

CButton *btnWhatever = new CButton;

BtnWhatever->Create(“Whatever”, WS_CHILD | WS_VISIBLE,
Crect(10, 362, 126, 385), this, 0x122);

Return bResult;
}

When the user clicks the Back button, the CPropertyPage::OnWizardBack() event
fires, giving you the opportunity to do what you judge necessary. Its syntax is:

virtual LRESULT OnWizardBack();

You should use this event on a page that has the Back button and if this button is enabled.
When the user clicks the Next button, the CPropertyPage::OnWizardNext() event fires,
allowing you to take appropriate measures. Its syntax is:

virtual LRESULT OnWizardNext();

You should use this event on a page that has the Next button. When the user clicks the
Finish button, the CPropertyPage::OnWizardFinish() event fires. Its syntax is:

virtual BOOL OnWizardFinish( );

This event should be implement when either the user is on the last page that has the
Finish button or at any time if the wizard has a permanent Finish button available on all
pages.

Practical Learning: Implementing Wizard Buttons



  1. Access the events of the CPersonalInfo class and fire its OnSetActive.

  2. Implement it as follows:


BOOL CPersonalInfo::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
CPropertySheet *EmplSheet = reinterpret_cast<CPropertySheet *>(GetParent());
Free download pdf