In Delphi, there is FormCloseQuery event. What is equivalent in MFC?
I want to stop CMainFrame from closing
In Delphi, there is FormCloseQuery 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
}
}