You are on page 1of 2

How to disable Cancel button on a property page?

Override OnSetActive of your propery page and write this code :

BOOL CMyPropertyPage8::OnSetActive()
{
//
CancelToClose();
return CPropertyPage::OnSetActive();
}

Here CancelToClose method changes Ok button to Close and disables Cancel button.

How to change Next button of property page to Finish?

Override OnSetActive() of that page which you want to have Finish button and write this code :

BOOL CMyPropertyPage8::OnSetActive()
{
CMyPropertySheet * parent=(CMyPropertySheet *)GetParent();
parent->SetWizardButtons(PSWIZB_BACK|PSWIZB_FINISH);
return CPropertyPage::OnSetActive();
}

Here first line returns a pointer to your PropertySheet class and SetWizardButtons method changes the
name of buttons.

And now override OnWizardFinish to handle finish button's click event :

BOOL CMyPropertyPage8::OnWizardFinish()
{
// TODO: Add your specialized code here and/or call the base class
return CPropertyPage::OnWizardFinish();
}

How to change caption of a button of a Property Page?

Override OnSetActive() of that page which you want to have Finish button and write this code :

CButton* pButton=(CButton*)GetDlgItem(PSWIZB_BACK);
pButton->SetWindowText("myname");

Where PSWIZB_FINISH, PSWIZB_NEXT, PSWIZB_CLOSE etc are the IDs of corresponding buttons.

How to delete a Property Page from Wizard?

When you use a Property Sheet wizard, it asks you how many pages you want in your wizard. Suppose
you have added 5 page to your Property Sheet Wizard and now you don't want a particular page. You can
remove that page easily by commenting one line of code in your propertysheet class's constructor. When
you see Constructor of your PropertySheet class, you will see that wizard calls AddPage method of
PropertySheet to add new page in the wizard. Ok, here is constructor for 5 pages :

CMyPropertySheet::CMyPropertySheet(CWnd* pWndParent)
: CPropertySheet(IDS_PROPSHT_CAPTION, pWndParent)
{
// Add all of the property pages here. Note that
// the order that they appear in here will be
// the order they appear in on screen. By default,
// the first page of the set is the active one.
// One way to make a different property page the
// active one is to call SetActivePage().
AddPage(&m_Page1);
AddPage(&m_Page2);
AddPage(&m_Page3);
AddPage(&m_Page4);
AddPage(&m_Page5);
SetWizardMode();
}

Now, let's say you don't want page # 3 to be diplayed. Just comment that line here.

CMyPropertySheet::CMyPropertySheet(CWnd* pWndParent)
: CPropertySheet(IDS_PROPSHT_CAPTION, pWndParent)
{
// Add all of the property pages here. Note that
// the order that they appear in here will be
// the order they appear in on screen. By default,
// the first page of the set is the active one.
// One way to make a different property page the
// active one is to call SetActivePage().
AddPage(&m_Page1);
AddPage(&m_Page2);
//AddPage(&m_Page3);
AddPage(&m_Page4);
AddPage(&m_Page5);
SetWizardMode();
}

Alternatively, you can call RemovePage method of PropertySheet to remove a page.

MORE : Call GetPageCount method to count number of pages in a propertysheet. Call GetActivePage to
get active page. You can use SetFinishText to change text for the Finish button.

You might also like