共用方式為


Closing the Dialog Box

OverviewHow Do I

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 member function of class CDialog in the Class Library 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   Life Cycle of a Dialog Box