In Delphi, there is F开发者_开发知识库ormCloseQuery event. What is equivalent in MFC?
I want to stop CMainFrame from closing
1) Add a handler to the WM_CLOSE message in your CMainFrame Message Map:
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
...
ON_WM_CLOSE()
...
END_MESSAGE_MAP()
2) Add afx_msg void OnClose(); to class definition in the header file
3) Add CMainFrame::OnClose() implementation
void CMainFrame::OnClose()
{
if (okToClose)
{
CFrameWnd::OnClose();
}
else
{
// Do nothing
}
}
精彩评论