开发者

FormCloseQuery equivalent in MFC

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜