如何在MFC中捕获WM_SHOWWINDOW命令
每当显示对话框时我都尝试执行一些操作。就像我们有无模式对话框,并且我们在单击某些按钮时隐藏/显示对话框。但是每当显示对话框时我们都需要执行一些操作。我已添加 WM_SHOWWINDOW 消息,但控件未进入 OnShowWindow(BOOL bShow, UINT nStatus) 函数内部。
我们使用 ShowWindow(SW_HIDE) 和 ShowWindow(SW_SHOW) 函数来隐藏/显示对话框 请建议一些如何实现这一目标的指示。
预先感
谢穆克什
I am trying to do some action whenever dialog box is Shown. Its like we have modalless dialog, and we are hinding/showing the dialog on some button click. But we we need to perfomr some action whenever dialog is shown. I have added the WM_SHOWWINDOW message but control is not coming inside of OnShowWindow(BOOL bShow, UINT nStatus) function.
We are using ShowWindow(SW_HIDE) and ShowWindow(SW_SHOW) function to hide/show dialog box
Please suggest some pointer how to achieve that.
Thanks in advance
Mukesh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用记事本和 Spy++ 使用以下代码对此进行了测试:
为了隐藏窗口,您应该获得 WM_SHOWWINDOW、WM_WINDOWPOSCHANGING,最后是 WM_WINDOWPOSCHANGED。
为了显示窗口,目标没有收到 WM_SHOWWINDOW,但仍然收到 WM_WINDOWPOSCHANGING 和 WM_WINDOWPOSCHANGED。
您可以处理 WM_WINDOWPOSCHANGED 并检查 WINDOWPOS 中 SWP_HIDEWINDOW/SWP_SHOWWINDOW 的标志。
I tested this with notepad and Spy++ with the following code:
For hiding the window, you should be getting WM_SHOWWINDOW, WM_WINDOWPOSCHANGING, then finally WM_WINDOWPOSCHANGED.
For showing the window, the target did not receive WM_SHOWWINDOW, but still got WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED.
You could handle WM_WINDOWPOSCHANGED and check the flags in WINDOWPOS for SWP_HIDEWINDOW/SWP_SHOWWINDOW.