开发者

FormCloseQuery equivalent in MFC

开发者 https://www.devze.com 2023-01-03 21:52 出处:网络
In Delphi, there is F开发者_开发知识库ormCloseQuery event. What is equivalent in MFC? I want to stop CMainFrame from closing1) Add a handler to the WM_CLOSE message in your CMainFrame Message Map:

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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消