在MainFrame中怎么调用Onclose();
按书上一个样例程序,在MainFrame中写了个Onclose(),退出时,会弹出对话框问是不是关,但怎么点右上角的X,也不出现,似乎没用调用到自己写的Onclose(),怎么回事?
void CMainFrame::OnClose()
{
if (AfxMessageBox("Do you really want to exit?",MB_YESNO)==IDYES)
{
CMDIFrameWnd::OnClose();
}
}
[解决办法]
你看一下你程序中下面这些都有没有:
1、在MainFrm.h中定义函数:afx_msg void OnClose();
2、在MainFrm.cpp中添加消息:ON_WM_CLOSE()
[解决办法]
onclose是对话框 , ondestroy吧
[解决办法]