Differences between cdialog: onok () and cdialog: oncancel ()
If data exchange exists in the program, onok can be automatically updated and verified. Oncancel does not perform this operation.
Msdn explanation:
Cdialog: onok
Called when the user clicks the OK button (the button with an ID of idok ).
Virtual void onok ();
Remarks
Override this member function to perform the OK button action. if the dialog box between des 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 callenddialog, which makes the dialog box invisible but does not destroy it.
Cdialog: oncancel
The framework callthis member function when the user clicks the cancel button or presses the ESC key in a modal or modeless dialog box.
Virtual void oncancel ();
Remarks
Override this member function to perform cancel button action. The default simply terminates a modal dialog box by calling enddialog and causing domodal to return idcancel.
If you implement the cancel button in a modeless dialog box, you must override the oncancel member function and call destroywindow from within it. don't call the base-class member function, because it callenddialog, which will make the dialog box invisible but not destroy it.
Source code:
Void cdialog: onok ()
{
If (! Updatedata (true ))
{
Trace (traceappmsg, 0, "updatedata failed during dialog termination./N ");
// The updatedata routine will set focus to correct item
Return;
}
Enddialog (idok );
}
Void cdialog: oncancel ()
{
Enddicel (idcancel );
}