virtual void OnOK( );
Remarks
Called when the user clicks the OK button (the button with an ID of IDOK).
Override this member function to perform the OK button action. If the dialog box includes automatic data validation and exchange, the default implementation of this member function validates the dialog-box data and updates the appropriate variables in your application.
If you implement the OK button in a modeless dialog box, you must override the OnOK member function and call DestroyWindow from within it. Don’t call the base-class member function, because it calls EndDialog, which makes the dialog box invisible but does not destroy it.
Example
// MyDialog.cpp
#include "MyDialog.h"
void CMyDialog::OnOK()
{
// TODO: Add extra validation here
// Ensure that your UI got the necessary input
// from the user before closing the dialog. The
// default OnOK will close this.
if ( m_nMyValue == 0 ) // Is a particular field still empty?
{
AfxMessageBox("Please enter a value for MyValue");
return; // Inform the user that he can't close the dialog without
// entering the necessary values and don't close the
// dialog.
}
CDialog::OnOK(); // This will close the dialog and DoModal will return.
}
CDialog Overview | Class Members | Hierarchy Chart
See Also CDialog::OnCancel, CDialog::EndDialog