共用方式為


CPropertyPage 類別

表示屬性工作表的個別頁面,也稱為索引標籤對話方塊。

語法

class CPropertyPage : public CDialog

成員

公用建構函式

名稱 描述
CPropertyPage::CPropertyPage 建構 CPropertyPage 物件。

公用方法

名稱 描述
CPropertyPage::CancelToClose 變更 [確定] 按鈕以讀取 [關閉],並在強制響應屬性表頁面的無法復原變更之後停用 [取消] 按鈕。
CPropertyPage::Construct 建構 CPropertyPage 物件。 Construct如果您要在執行時間指定參數,或是使用數位,請使用 。
CPropertyPage::GetPSP 擷取與 CPropertyPage 對象相關聯的 Windows PROPSHEETPAGE 結構。
CPropertyPage::OnApply 按兩下 [ 立即 套用] 按鈕時,由架構呼叫。
CPropertyPage::OnCancel 按兩下 [取消] 按鈕時,由架構呼叫。
CPropertyPage::OnKillActive 當目前頁面不再是使用中頁面時,由架構呼叫。 在這裡執行數據驗證。
CPropertyPage::OnOK 按兩下 [確定]、[立即套用] 或 [關閉] 按鈕時,由架構呼叫。
CPropertyPage::OnQueryCancel 按兩下 [取消] 按鈕,並在取消發生之前,由架構呼叫。
CPropertyPage::OnReset 按兩下 [取消] 按鈕時,由架構呼叫。
CPropertyPage::OnSetActive 當頁面成為使用中頁面時,由架構呼叫。
CPropertyPage::OnWizardBack 使用精靈類型屬性表時按兩下 [上一頁] 按鈕時,由架構呼叫。
CPropertyPage::OnWizardFinish 使用精靈類型屬性表時按兩下 [完成] 按鈕時,由架構呼叫。
CPropertyPage::OnWizardNext 使用精靈類型屬性表時按兩下 一步 按鈕時,由架構呼叫。
CPropertyPage::QuerySiblings 將訊息轉寄至屬性表的每個頁面。
CPropertyPage::SetModified 呼叫 以啟動或停用 [ 立即 套用] 按鈕。

公用資料成員

名稱 描述
CPropertyPage::m_psp Windows PROPSHEETPAGE 結構。 提供基本屬性頁參數的存取權。

備註

如同標準對話框,您會從 CPropertyPage 屬性表中的每個頁面衍生類別。 若要使用 CPropertyPage衍生的物件,請先建立 CPropertySheet 對象,然後針對屬性表中的每個頁面建立 物件。 呼叫 CPropertySheet::AddPage 工作表中的每個頁面,然後呼叫強制響應屬性表 CPropertySheet::DoModalCPropertySheet::Create 無模式屬性表來顯示屬性表。

您可以建立稱為精靈的索引卷標對話框類型,其中包含一連串屬性頁的屬性表,引導使用者完成作業的步驟,例如設定裝置或建立電子報。 在精靈類型索引標籤對話框中,屬性頁沒有索引標籤,而且一次只能顯示一個屬性頁。 此外,精靈類型索引標籤對話框沒有 [確定] 和 [立即套用] 按鈕,而是具有 [上一步] 或 [完成] 按鈕,以及 [取消] 按鈕。

如需建立屬性表做為精靈的詳細資訊,請參閱 CPropertySheet::SetWizardMode。 如需使用 CPropertyPage 對象的詳細資訊,請參閱屬性表和屬性頁一文

繼承階層架構

CObject

CCmdTarget

CWnd

CDialog

CPropertyPage

需求

標頭: afxdlgs.h

CPropertyPage::CancelToClose

在對強制回應屬性表頁面中的數據進行無法復原的變更之後,呼叫此函式。

void CancelToClose();

備註

此函式會將 [ 確定] 按鈕變更為 [關閉 ],並停用 [ 取消] 按鈕。 這項變更會提醒用戶變更是永久的,而且無法取消修改。

成員 CancelToClose 函式不會在無模式屬性表中執行任何動作,因為無模式屬性表預設沒有 [ 取消 ] 按鈕。

範例

請參閱 CPropertyPage::QuerySiblings 的範例

CPropertyPage::Construct

呼叫這個成員函式以建構 CPropertyPage 物件。

void Construct(
    UINT nIDTemplate,
    UINT nIDCaption = 0);

void Construct(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption = 0);

void Construct(
    UINT nIDTemplate,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0);

void Construct(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0);

參數

nIDTemplate
用於此頁面的範本識別碼。

nIDCaption
要置於此頁面索引標籤中之名稱的識別碼。 如果為 0,則會從此頁面的對話框範本取得名稱。

lpszTemplateName
包含以 Null 結尾的字串,此字串是範本資源的名稱。

nIDHeaderTitle
要放在屬性頁首標題位置的名稱標識碼。 根據預設,0。

nIDHeaderSubTitle
要放在屬性頁首之子標題位置的名稱標識碼。 根據預設,0。

備註

符合下列所有條件之後,就會顯示物件:

Construct如果尚未呼叫其他其中一個類別建構函式,請呼叫 。 成員 Construct 函式具有彈性,因為您可以將parameter語句保留空白,然後在程式代碼中的任何時間點指定多個參數和建構。

當您使用陣列時,必須使用 Construct ,而且您必須針對陣列的每個成員呼叫 Construct ,讓數據成員獲派適當的值。

範例

// Declare a CPropertySheet object.
CPropertySheet sheet(_T("Simple PropertySheet"));

// Create three CPropertyPage objects whose template IDs are specified
// in rgID array, and add each page to the CPropertySheet object. 
const int c_cPages = 3;
CPropertyPage   pages[c_cPages];
UINT rgID[c_cPages] = { IDD_STYLE, IDD_COLOR, IDD_SHAPE };
for (int i = 0; i < c_cPages; i++)
{
   pages[i].Construct(rgID[i]);
   sheet.AddPage(&pages[i]);
}

// Display a modal CPropertySheet dialog.
sheet.DoModal();

CPropertyPage::CPropertyPage

建構 CPropertyPage 物件。

CPropertyPage();

explicit CPropertyPage(
    UINT nIDTemplate,
    UINT nIDCaption = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

explicit CPropertyPage(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

CPropertyPage(
    UINT nIDTemplate,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

CPropertyPage(
    LPCTSTR lpszTemplateName,
    UINT nIDCaption,
    UINT nIDHeaderTitle,
    UINT nIDHeaderSubTitle = 0,
    DWORD dwSize = sizeof(PROPSHEETPAGE));

參數

nIDTemplate
用於此頁面的範本識別碼。

nIDCaption
要置於此頁面索引標籤中之名稱的識別碼。 如果為 0,則會從此頁面的對話框範本取得名稱。

dwSize
lpszTemplateName 指向包含此頁面範本名稱的字串。 不能為 NULL

nIDHeaderTitle
要放在屬性頁首標題位置的名稱標識碼。

nIDHeaderSubTitle
要放在屬性頁首之子標題位置的名稱標識碼。

備註

符合下列所有條件之後,就會顯示物件:

如果您有多個參數(例如,如果您使用陣列),請使用 CPropertySheet::Construct 而非 CPropertyPage

範例

// Declare a CStylePage object, which is a CPropertyPage-derived class.
CStylePage stylePage;

// Declare a CPropertyPage object with IDD_SHAPE, the ID of the 
// template used for this page. 
CPropertyPage shapePage(IDD_SHAPE);

CPropertyPage::GetPSP

擷取與 CPropertyPage 對象相關聯的 Windows PROPSHEETPAGE 結構。

const PROPSHEETPAGE& GetPSP() const;

PROPSHEETPAGE& GetPSP();

傳回值

結構的 PROPSHEETPAGE 參考。

CPropertyPage::m_psp

m_psp 是結構,其成員會儲存的特性 PROPSHEETPAGE

PROPSHEETPAGE m_psp;

備註

使用此結構來初始化屬性頁建構之後的外觀。

如需此結構的詳細資訊,包括其成員的清單,請參閱 PROPSHEETPAGE Windows SDK。

範例

CPropertySheet sheet(_T("Simple PropertySheet"));

// Change the settings of the three pages to enable property sheet's 
// Help button when the page is active.  CStylePage, CShapePage, and 
// CColorPage are CPropertyPage-derived classes.
CStylePage pageStyle;
pageStyle.m_psp.dwFlags |= PSP_HASHELP;

CColorPage pageColor;
pageColor.m_psp.dwFlags |= PSP_HASHELP;

CShapePage pageShape;
pageShape.m_psp.dwFlags |= PSP_HASHELP;

sheet.AddPage(&pageStyle);
sheet.AddPage(&pageColor);
sheet.AddPage(&pageShape);

sheet.SetWizardMode();

sheet.DoModal();

CPropertyPage::OnApply

當使用者選擇 [ 確定 ] 或 [立即 套用] 按鈕時,架構會呼叫此成員函式。

virtual BOOL OnApply();

傳回值

如果接受變更,則為非零;否則為 0。

備註

當架構呼叫此函式時,會接受屬性表中所有屬性頁所做的變更、屬性表會保留焦點,並 OnApplyTRUE 回 (值 1)。 您OnApply必須先呼叫 並將其參數設定為 TRUE,才能由架構呼叫SetModified。 當使用者在屬性頁面上進行變更時,這會立即啟動 [立即 套用] 按鈕。

覆寫此成員函式,以指定當用戶選取 [ 立即 套用] 按鈕時,您的程式採取什麼動作。 覆寫時,函式應該會返回 TRUE 接受變更,並 FALSE 防止變更生效。

OnApply 的預設實作會呼叫 OnOK

如需當使用者按下屬性表中的 [立即 套用] 或 [確定 ] 按鈕時所傳送通知訊息的詳細資訊,請參閱 PSN_APPLY Windows SDK。

範例

請參閱 CPropertyPage::OnOK範例。

CPropertyPage::OnCancel

選取 [ 取消 ] 按鈕時,架構會呼叫此成員函式。

virtual void OnCancel();

備註

覆寫此成員函式以執行 [取消 ] 按鈕動作。 預設會否定任何已進行的變更。

範例

// Discard any selection the user made to this page.  The object
// in the view will be painted with the initial color when the
// CPropertySheet dialog is first shown. CColorPage is a 
// CPropertyPage-derived class.
void CColorPage::OnCancel()
{
   // Reset the color saved in the document class.  m_InitialColor
   // is a member variable of CColorPage and it is the color shown 
   // in the view before CPropertySheet is shown.
   // doc->m_Color is the color saved in the document class, and 
   // this is the color to be used by the view class.
   CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetMainWnd();
   CMDIChildWnd* pChild = pFrame->MDIGetActive();
   CPSheetDoc* doc = (CPSheetDoc*)pChild->GetActiveDocument();
   doc->m_Color = m_InitialColor;

   // Tell the view to paint with the initial color.
   CView* view = pChild->GetActiveView();
   view->Invalidate();

   CPropertyPage::OnCancel();
}

// The default MFC implementation of OnReset() would call OnCancel().
void CColorPage::OnReset()
{
   CPropertyPage::OnReset();
}

CPropertyPage::OnKillActive

當頁面不再是使用中頁面時,架構會呼叫此成員函式。

virtual BOOL OnKillActive();

傳回值

如果數據已成功更新,則為非零,否則為 0。

備註

覆寫此成員函式以執行特殊數據驗證工作。

這個成員函式的預設實作會將設定從屬性頁中的控件複製到屬性頁的成員變數。 如果數據因為對話數據驗證 (DDV) 錯誤而未成功更新,頁面會保留焦點。

成功傳回此成員函式之後,架構會呼叫頁面的 OnOK 函式。

範例

// Validate the value entered to the "Number" edit control. Its
// value must be at least one. If not, tell the user and set the
// focus to the "Number" edit control. CStylePage is a 
// CPropertyPage-derived class.
BOOL CStylePage::OnKillActive() 
{
   int num = GetDlgItemInt(IDC_NUMOBJECTS);
   if (num <= 0)
   {
      AfxMessageBox(_T("Number of objects must be at least 1."));
      CEdit* edit = (CEdit*) GetDlgItem(IDC_NUMOBJECTS);
      edit->SetFocus();
      edit->SetSel(0, -1);
      return 0;
   }

   return CPropertyPage::OnKillActive();
}

CPropertyPage::OnOK

當使用者選擇 [確定 ] 或 [立即 套用] 按鈕時,架構會立即呼叫 OnKillActive此成員函式。

virtual void OnOK();

備註

當使用者選擇 [確定] 或 [立即套用] 按鈕時,架構會PSN_APPLY從屬性頁接收通知。 如果您呼叫 OnOK ,則不會呼叫 CPropertySheet::PressButton ,因為屬性頁在該情況下不會傳送通知。

覆寫此成員函式,以在使用者關閉整個屬性表時,實作目前使用中頁面特有的其他行為。

此成員函式的預設實作會將頁面標示為「乾淨」,以反映函式中的數據 OnKillActive 已更新。

範例

// Accept the new color selection and dismiss the CPropertySheet
// dialog. The view's object will be painted with the new selected
// color. CColorPage is a CPropertyPage-derived class.
void CColorPage::OnOK() 
{
   // Store the new selected color to a member variable of 
   // document class.  m_Color is a member varible of CColorPage 
   // and it stores the new selected color.  doc->m_Color is 
   // the color saved in the document class and it is the color 
   // used by the view class.
   CMDIFrameWnd* pframe = (CMDIFrameWnd*) AfxGetMainWnd();
   CMDIChildWnd* pchild = pframe->MDIGetActive();
   CPSheetDoc* doc = (CPSheetDoc*) pchild->GetActiveDocument();
   doc->m_Color = m_Color;

   // Tell the view to paint with the new selected color.
   CView* view = pchild->GetActiveView();
   view->Invalidate();
  
   CPropertyPage::OnOK();
}

// The default MFC implementation of OnApply() would call OnOK().
BOOL CColorPage::OnApply() 
{
   return CPropertyPage::OnApply();
}

CPropertyPage::OnQueryCancel

當使用者選取 [取消 ] 按鈕,並在取消動作發生之前,由架構呼叫此成員函式。

virtual BOOL OnQueryCancel();

傳回值

FALSE傳回 以防止取消作業或TRUE允許它。

備註

覆寫此成員函式,以指定當用戶選取 [取消 ] 按鈕時程式所採取動作。

預設實作 OnQueryCancel 會傳 TRUE回 。

範例

// Query the user whether to abort the changes if the new selected
// color (m_Color) is different from the initial color 
// (m_InitialColor) when the CPropertySheet dialog is first shown.
// CColorPage is a CPropertyPage-derived class.
BOOL CColorPage::OnQueryCancel() 
{
   if (m_InitialColor != m_Color)
   {
      if (AfxMessageBox(_T("Abort the changes?"), MB_YESNO) == IDNO)
         return FALSE;  
   }

   return CPropertyPage::OnQueryCancel();
}

CPropertyPage::OnReset

當使用者選擇 [ 取消 ] 按鈕時,架構會呼叫此成員函式。

virtual void OnReset();

備註

當架構呼叫此函式時,會捨棄使用者先前選擇 [立即套用 ] 按鈕的所有屬性頁變更,而屬性表會保留焦點。

覆寫此成員函式,以指定當用戶選取 [取消 ] 按鈕時程序採取什麼動作。

的預設實 OnReset 作不會執行任何動作。

範例

請參閱 CPropertyPage::OnCancel範例。

CPropertyPage::OnSetActive

當使用者選擇頁面並成為使用中頁面時,架構會呼叫此成員函式。

virtual BOOL OnSetActive();

傳回值

如果頁面已成功設定為使用中,則為非零;否則為 0。

備註

覆寫此成員函式,以在啟用頁面時執行工作。 此成員函式的覆寫通常會在更新數據成員之後呼叫預設版本,以允許它以新的數據更新頁面控件。

如果先前未建立,預設實作會建立頁面的視窗,並使它成為使用中的頁面。

範例

請參閱 CPropertySheet::SetFinishText範例。

CPropertyPage::OnWizardBack

當使用者在精靈中選取 [上一頁 ] 按鈕時,架構會呼叫此成員函式。

virtual LRESULT OnWizardBack();

傳回值

0 自動前進到下一頁;-1 以防止頁面變更。 若要跳至下一個頁面以外的頁面,請傳回要顯示的對話框識別碼。

備註

覆寫此成員函式,以指定按下 [上一步] 按鈕時用戶必須採取的一些動作。

如需如何建立精靈類型屬性表的詳細資訊,請參閱 CPropertySheet::SetWizardMode

範例

// The Back button is selected from the propertysheet.  Get the selected 
// radio button of the page by looping through all buttons on the 
// pages.  m_radioColor is a member variable of 
// CColorPage (a CPropertyPage-derived class).  Its initial value 
// is initialized in OnInitDialog().
LRESULT CColorPage::OnWizardBack()
{
   for (int id = IDC_RADIOBLACK; id <= IDC_RADIOGREEN; id++)
   {
      CButton* button = (CButton*)GetDlgItem(id);
      if (button->GetCheck() == 1)
      {
         m_radioColor = id - IDC_RADIOBLACK;
         break;
      }
   }

   return CPropertyPage::OnWizardBack();
}

CPropertyPage::OnWizardFinish

當使用者在精靈中選取 [完成 ] 按鈕時,架構會呼叫此成員函式。

virtual BOOL OnWizardFinish();

傳回值

當精靈完成時,如果屬性表被終結,則為非零;否則為零。

備註

當使用者在精靈中選取 [完成] 按鈕時,架構會呼叫此函式;當傳回 TRUE (非零值) 時OnWizardFinish,屬性表就能夠終結(但實際上並未終結)。 呼叫 DestroyWindow 以終結屬性表。 請勿從OnWizardFinish呼叫 DestroyWindow ;這樣做會導致堆積損毀或其他錯誤。

您可以覆寫此成員函式,以指定按下 [完成] 按鈕時用戶必須採取的一些動作。 覆寫此函式時,傳回 FALSE 以防止屬性表被終結。

如需使用者按下精靈屬性表中 [ 完成] 按鈕時所傳送通知訊息的詳細資訊,請參閱 PSN_WIZFINISH Windows SDK。

如需如何建立精靈類型屬性表的詳細資訊,請參閱 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);
}

CPropertyPage::OnWizardNext

當使用者在精靈中選取 [ 下一步 ] 按鈕時,架構會呼叫此成員函式。

virtual LRESULT OnWizardNext();

傳回值

0 自動前進到下一頁;-1 以防止頁面變更。 若要跳至下一個頁面以外的頁面,請傳回要顯示的對話框識別碼。

備註

覆寫此成員函式,以指定按下 [ 下一步 ] 按鈕時用戶必須採取的一些動作。

如需如何建立精靈類型屬性表的詳細資訊,請參閱 CPropertySheet::SetWizardMode

範例

// The Next button is selected from the propertysheet. Show the 
// second page of the propertysheet ONLY if a non-zero value is 
// entered to the Number edit control of the CStylePage. Otherwise
// display a message to the user and stay on the current page.

LRESULT CStylePage::OnWizardNext()
{
   // Get the number from the edit control
   int num = GetDlgItemInt(IDC_NUMOBJECTS);

   if (num == 0)
   {
      // Display a message to the user
      AfxMessageBox(_T("Supply a non-zero number on the edit control"), MB_OK);

      // Stay on the current page
      return -1;
   }

   // CPropertyPage::OnWizardNext returns zero and causes
   // the property sheet to display the next page
   return CPropertyPage::OnWizardNext();
}

CPropertyPage::QuerySiblings

呼叫這個成員函式,將訊息轉送至屬性表中的每個頁面。

LRESULT QuerySiblings(
    WPARAM wParam,
    LPARAM lParam);

參數

wParam
指定其他訊息相依資訊。

lParam
指定其他訊息相依資訊

傳回值

屬性表中頁面的非零值,如果所有頁面都傳回值 0,則為 0。

備註

如果頁面傳回非零值,則屬性表不會將訊息傳送至後續頁面。

範例

// Validate the value entered in the Number edit control. If its 
// value is not a natural number, request CPropertySheet (i.e. parent
// window of the page) to send a PSM_QUERYSIBLINGS message to each
// LOADED page (a page won't be loaded in memory until it is shown).
// If one of the pages returns a nonzero value in response to the 
// PSM_QUERYSIBLINGS message, then inform the user and change the OK
// to Close and disable the Cancel button. CStylePage is a 
// CPropertyPage-derived class.
BOOL CStylePage::OnApply()
{
   int num = GetDlgItemInt(IDC_NUMOBJECTS);
   if (num <= 0)
   {
      if (QuerySiblings(num, 0L))
      {
         AfxMessageBox(_T("Invalid data is entered.  Choose Close ")
            _T("button to close the dialog."));
         CancelToClose();
      }
   }

   return CPropertyPage::OnApply();
}

 

// This is an example of trapping the PSM_QUERYSIBLINGS in one of
// the pages. CColorPage is a CPropertyPage-derived class.  Upon 
// receiving this message, wParam contains the value passed to 
// QuerySiblings() call. CColorPage will check this value and return
// FALSE only if the value is greater than 1.
ON_MESSAGE(PSM_QUERYSIBLINGS, &CColorPage::OnQuerySiblings)

 

LRESULT CColorPage::OnQuerySiblings(WPARAM wParam, LPARAM lParam)
{
   UNREFERENCED_PARAMETER(lParam);
   return (wParam <= 0);
}

CPropertyPage::SetModified

呼叫這個成員函式,根據屬性頁中的設定是否應套用至適當的外部物件,啟用或停用 [立即套 用] 按鈕。

void SetModified(BOOL bChanged = TRUE);

參數

bChanged
TRUE 表示屬性頁設定自上次套用後已修改; FALSE 表示已套用屬性頁設定,或應該忽略。

備註

架構會追蹤哪些頁面是「肮髒」的,也就是您已呼叫 SetModified( TRUE )的屬性頁。 如果您呼叫SetModified( TRUE )其中一個頁面,一律會啟用 [立即套用] 按鈕。 當您呼叫SetModified( FALSE )其中一個頁面時,將會停用 [立即套用] 按鈕,但前提是沒有其他頁面是「肮髒」的。

範例

// OnColorClicked() is a member function of CColorPage (a
// CPropertyPage-derived class). It is called whenever a radio button
// is selected on the page. Call SetModified() to enable the Apply 
// button whenever a new selection is made. m_Color is a member
// variable of CColorPage and it is to store the selected RGB color.
// Its entry in the message map looks like this:
// ON_CONTROL_RANGE(BN_CLICKED, IDC_BLACK, IDC_GREEN, CColorPage::OnColorClicked)
void CColorPage::OnColorClicked(UINT nCmdID)
{
   COLORREF color = m_Color;
   switch (nCmdID)
   {
   case IDC_RADIOBLACK:
      color = RGB(0, 0, 0);
      m_radioColor = crBlack;
      break;

   case IDC_RADIORED:
      color = RGB(255, 0, 0);
      m_radioColor = crRed;
      break;

   case IDC_RADIOGREEN:
      color = RGB(0, 255, 0);
      m_radioColor = crGreen;
      break;

   case IDC_RADIOBLUE:
      color = RGB(0, 0, 255);
      m_radioColor = crBlue;
      break;
   }

   if (color != m_Color)
   {
      m_Color = color;
      SetModified();    // Enable Apply Now button.
   }

   UpdateData(FALSE);
}

另請參閱

MFC 範例 CMNCTRL1
MFC 範例 CMNCTRL2
MFC 範例 PROPDLG
MFC 範例 SNAPVW
CDialog
階層架構圖表
CPropertySheet