你这个应该是非模态对话框吧 MSDN中有一段话解释得很清楚: 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 calls EndDialog, which will make the dialog box invisible but not destroy it. 对于非模态对话框来说,OnCancel并不真正的关闭对话框,而只是将它隐藏了起来。
Override this method to perform actions (such as restoring old data) when a user closes the dialog box by clicking Cancel or hitting the ESC key. The default closes 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 method and call DestroyWindow inside it. Do not call the base-class method, because it calls EndDialog, which will make the dialog box invisible but not destroy it.
MSDN中有一段话解释得很清楚:
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 calls EndDialog, which will make the dialog box invisible but not destroy it.
对于非模态对话框来说,OnCancel并不真正的关闭对话框,而只是将它隐藏了起来。