Commonly Overridden Member Functions
The following table lists the most likely member functions to override in your CDialog-derived class.
Message it responds to
Purpose of the override
Initialize the dialog box's controls.
BN_CLICKED for button IDOK
Respond when the user clicks the OK button.
BN_CLICKED for button IDCANCEL
Respond when the user clicks the Cancel button.
OnInitDialog, OnOK, and OnCancel are virtual functions. To override them, you declare an overriding function in your derived dialog class using the Properties window.
OnInitDialog is called just before the dialog box is displayed. You must call the default OnInitDialog handler from your override — usually as the first action in the handler. By default, OnInitDialog returns TRUE to indicate that the focus should be set to the first control in the dialog box.
OnOK is typically overridden for modeless but not modal dialog boxes. If you override this handler for a modal dialog box, call the base class version from your override — to ensure that EndDialog is called — or call EndDialog yourself.
OnCancel is usually overridden for modeless dialog boxes.