Udostępnij za pośrednictwem


Closing the Dialog Box

A modal dialog box closes when the user chooses one of its buttons, typically the OK button or the Cancel button. Choosing the OK or Cancel button causes Windows to send the dialog object a BN_CLICKED control-notification message with the button's ID, either IDOK or IDCANCEL. CDialog provides default handler functions for these messages: OnOK and OnCancel. The default handlers call the EndDialog member function to close the dialog window. You can also call EndDialog from your own code. For more information, see the EndDialog member function of class CDialog in the MFC Reference.

To arrange for closing and deleting a modeless dialog box, override PostNcDestroy and invoke the delete operator on the this pointer. Destroying the Dialog Box explains what happens next.

See Also

Concepts

Life Cycle of a Dialog Box