Partager via


CPropertyPage::OnOK

This member function is called by the framework when the user chooses either the OK or the Apply Now button, immediately after the framework calls OnKillActive.

virtual void OnOK( );

Remarks

When the user chooses either the OK or the Apply Now button, the framework receives the PSN_APPLY notification from the property page. The call to OnOK won't be made if you call CPropertySheet::PressButton because the property page does not send the notification in that case.

Override this member function to implement additional behavior specific to the currently active page when user dismisses the entire property sheet.

The default implementation of this member function marks the page as "clean" to reflect that the data was updated in the OnKillActive function.

Example

// 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();
}

Requirements

Header: afxdlgs.h

See Also

Reference

CPropertyPage Class

Hierarchy Chart

CDialog::OnOK

CPropertyPage::OnKillActive