如何知道控件何时将被隐藏
我有一个从 CWnd 对象派生的控件,该对象具有自定义实现的工具提示系统。 工具提示是使用 CDialog 实现的,工作正常,但我有一个问题,不知道何时必须隐藏它。
当鼠标悬停在控件上时(WM_MOUSEHOVER)会显示工具提示,当鼠标离开控件时(WM_MOUSELEAVE)会隐藏工具提示。 到目前为止,一切都很好。 问题是设置控件的对话框可以从菜单中隐藏(不破坏它可以从菜单中再次显示)。 发生这种情况时,WM_MOUSELEAVE 事件不会发送到控件,并且工具提示也不会删除......它出现在新对话框上。
我的问题是:有没有办法知道控件是否被隐藏? 我知道我可以捕获设置控件的对话框的 WM_SHOWWINDOW 消息,但我想从控件本身执行此操作,以便我可以在其他地方使用该控件,而无需添加额外的代码。
提前致谢!
哈维尔
I have a control derived from a CWnd object that has its custom implemented tooltip system . The tooltip is implemented using a CDialog and works fine but I have a problem to know when I have to hide it.
The tooltip shows up when the mouse hover over the control (WM_MOUSEHOVER) and it's hidden when the mouse leaves the control (WM_MOUSELEAVE). So far so good. The problem is that the dialog where the control is set can be hidden from the menu (not destroyed it can be displayed again from the menu). When this happens the WM_MOUSELEAVE event is not sent to the control and the tooltip is not removed...it appears over the new dialog.
My question is: is there a way to know that the control is being hidden? I know I can capture the WM_SHOWWINDOW message for the dialog where the control is set but I want to do it from the control itself so I can use the control elsewhere without having to add extra code.
Thanks in advance!
Javier
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,如果您有一个自定义控件需要将对话框消息转发给它,则可以使用子类化。 类似于下面的内容
,您可以处理来自控件的对话框消息,例如,
您仍然需要在较小程度上修改主机对话框代码才能使用该控件,但您的控件是可重用的。
Generally, if you have a custom control that needs to have dialog messages forwarded on to it you use sub-classing. Something like the following
then you can process dialog messages from your control, e.g.
You still have to modify host dialog code to a small extent to utilise the control, but your control is re-usable.