CPropertyPage::OnWizardFinish

更新 : 2007 年 11 月

ユーザーがウィザードの [完了] ボタンをクリックしたときに、フレームワークが呼び出します。

virtual BOOL OnWizardFinish( );

戻り値

ウィザードが終了したときにプロパティ シートが破棄される場合は 0 を以外を返します。それ以外の場合は 0 を返します。

解説

ウィザードの [完了] をクリックすると、フレームワークがこの関数を呼び出します。OnWizardFinishTRUE (0 以外の値) を返した場合、プロパティ シートは破棄できる状態にありますが、実際には破棄されません。DestroyWindow を呼び出し、プロパティ シートを破棄します。OnWizardFinish から DestroyWindow を呼び出さないでください。呼び出すと、ヒープの破損またはその他のエラーが発生します。

このメンバ関数をオーバーライドすると、[完了] ボタンがクリックされたときに、ユーザーが操作を行うように指定できます。この関数のオーバーライドでプロパティ シートが破棄されないようにするには FALSE を返します。

ユーザーがプロパティ シートの [完了] ボタンをクリックしたときに送られる通知メッセージの詳細については、Windows SDK の「PSN_WIZFINISH」を参照してください。

ウィザード型のプロパティ シートの作成方法の詳細については、「CPropertySheet::SetWizardMode」を参照してください。

使用例

// Inform users regarding the selections they have made by 
// navigating the pages in propertysheet.
BOOL CShapePage::OnWizardFinish()
{
   CString report = _T("You have selected the following options:\n");

   // Get the number of property pages from CPropertySheet.
   CPropertySheet* sheet = (CPropertySheet*) GetParent();
   int count = sheet->GetPageCount();   

   // Get the formatted string from each page. This formatted string 
   // will be shown in a message box. Each page knows about the 
   // string to be displayed. For simplicity, we derive a class 
   // from CPropertyPage called CMyPropertyPage. CMyPropertyPage 
   // has a pure virtual member function called GetPageSelections().
   // All pages in the property sheet must be derived from 
   // CMyPropertyPage so we loop through each page to get the 
   // formatted string by calling the GetPageSelections() function.
   for (int i = 0; i < count; i++)
   {
      CMyPropertyPage* page = (CMyPropertyPage*) sheet->GetPage(i);

      CString str;
      page->GetPageSelections(str);
      report += _T("\n") + str;
   }

   AfxMessageBox(report);

   return CPropertyPage::OnWizardFinish();
}
// An example of implementing the GetPageSelections() for CStylePage.
// CStylePage is a CMyPropertyPage-derived class, which in turn is a 
// CPropertyPage-derived class.
void CStylePage::GetPageSelections(CString &str)
{
   str.Format(_T("Number of objects to be created = %d"), m_NumObjects);
}
// An example of implementing the GetPageSelections() for CColorPage.
// CColorPage is a CMyPropertyPage-derived class, which in turn is a 
// CPropertyPage-derived class.
void CColorPage::GetPageSelections(CString &str)
{
   str = _T("Color selected is ");   
   switch (m_Color)
   {
   case RGB(0, 0, 0):
      str += _T("Black");
      break;

   case RGB(255, 0, 0):
      str += _T("Red");
      break;

   case RGB(0, 255, 0):
      str += _T("Green");
      break;

   case RGB(0, 0, 255):
      str += _T("Blue");
      break;

   default:
      str += _T("Custom");
      break;
   }
}
// An example of implementing the GetPageSelections() for CShapePage.
// CShapePage is a CMyPropertyPage-derived class, which in turn is a 
// CPropertyPage-derived class.
void CShapePage::GetPageSelections(CString &str)
{
   CString shapename;
   switch (m_Selection)
   {
   case IDC_RECTANGLE:
      shapename = _T("Rectangle");
      break;

   case IDC_ROUND_RECTANGLE:
      shapename = _T("Round Rectangle");
      break;

   case IDC_ELLIPSE:
      shapename = _T("Ellipse");
      break;
   }

   str.Format(_T("Shape to be created is %s"), shapename);
}

必要条件

ヘッダー : afxdlgs.h

参照

参照

CPropertyPage クラス

階層図

CPropertySheet::SetWizardMode

その他の技術情報

CPropertyPage のメンバ