如何在MDI中......

weizhisheng 2001-03-23 10:59:00
我想实现这样一个功能:在MDI程序中有固定个数的窗口,并且不允许用户关闭子窗口,只有主窗口关闭时,所有子窗口才自动关闭。请问如何实现?我查过wm_destroy,wm_close,发现没有我想要的CloseReason这个参数,这可如何是好?在Delphi里面可是有个OnCloseQuery函数可以实现这个功能,那VC应该也可以做得到吧?
如果退而求其次的话,我想我也有办法,就是自己拦截按关闭按钮的消息,双击系统按钮的消息,关闭快捷键的消息。。。可这也不好,在MDI要关闭一个子窗口至少有四五种办法,说不定还有我不知道的,一个一个拦截太那个了。
...全文
176 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
weizhisheng 2001-03-23
  • 打赏
  • 举报
回复
好办法!为什么我没有想到!谢谢tiongkohlang
tiongkohlang 2001-03-23
  • 打赏
  • 举报
回复
响应子窗口的WM_CLOSE,或在mfc中用OnClose.不要用缺省实现,返回一个0就行了。缺省实现会关闭常口
weizhisheng 2001-03-23
  • 打赏
  • 举报
回复
这位大哥有没有试过啊。。。我也想到过WM_QUERYENDSESSION,可是它只有在Windows结束的时候才被调用,不信你试试看。
joke100 2001-03-23
  • 打赏
  • 举报
回复
在框架中重载消息WM_QUERYENDSESSION即可

在MFC中可以使用BOOL CWnd::OnQueryEndSession();

The framework calls this member function when the user chooses to end the Windows session or when an application calls theExitWindows Windows function. If any application returns 0, the Windows session is not ended. Windows stops calling OnQueryEndSession as soon as one application returns 0 and sends the WM_ENDSESSION message with a parameter value of FALSE for any application that has already returned nonzero.

joke100 2001-03-23
  • 打赏
  • 举报
回复
在框架中重载消息WM_QUERYENDSESSION即可

在MFC中可以使用BOOL CWnd::OnQueryEndSession();

The framework calls this member function when the user chooses to end the Windows session or when an application calls theExitWindows Windows function. If any application returns 0, the Windows session is not ended. Windows stops calling OnQueryEndSession as soon as one application returns 0 and sends the WM_ENDSESSION message with a parameter value of FALSE for any application that has already returned nonzero.

joke100 2001-03-23
  • 打赏
  • 举报
回复
在框架中重载消息WM_QUERYENDSESSION即可

在MFC中可以使用BOOL CWnd::OnQueryEndSession();

The framework calls this member function when the user chooses to end the Windows session or when an application calls theExitWindows Windows function. If any application returns 0, the Windows session is not ended. Windows stops calling OnQueryEndSession as soon as one application returns 0 and sends the WM_ENDSESSION message with a parameter value of FALSE for any application that has already returned nonzero.

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧