CDialog::OnOK
Called when the user clicks the OK button (the button with an ID of IDOK).
virtual void OnOK( );
Remarks
Override this method to perform actions when the OK button is activated. If the dialog box includes automatic data validation and exchange, the default implementation of this method 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 method and call DestroyWindow inside it. Do not call the base-class method, because it calls EndDialog which makes the dialog box invisible but does not destroy it.
참고
You cannot override this method when you use a CFileDialog object in a program that is compiled under Windows XP. For more information about CFileDialog, see CFileDialog Class.
Example
void CSimpleDlg::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?
{
// Inform the user that he can't close the dialog without
// entering the necessary values and don't close the
// dialog.
AfxMessageBox(_T("Please enter a value for MyValue"));
return;
}
CDialog::OnOK(); // This will close the dialog and DoModal will return.
}
Requirements
Header: afxwin.h