参考代码如下:处理WM_CLOSE消息,CYourDlg::OnClose(){if(::MessageBox(NULL, 确定要退出吗?","程序退出", MB_YESNO) == IDYES){CDialog::OnCLose(); //OnCLose事件}}