- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 CTreeCtrl 派生类中,我作用于 TVN_ITEMEXPANDED:
ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, &OnTVNItemExpanded)
在控件的父对话框中,我也想对相同的通知 TVN_ITEMEXPANDED 采取行动,
ON_NOTIFY(TVN_ITEMEXPANDED, IDC_ELEMENT_TREE, &OnTVNItemExpanded)
但是,只有控件类的 OnTVNItemExpanded 方法被调用,我的对话框从来没有被调用。我使用了两个断点并在两种方法中都看到了所需的行为(或缺少所需的行为),以验证是否仅调用了控件类的方法,而不是我的对话框的方法。
但是,如果我从 CTreeCtrl 派生的 BEGIN_MESSAGE_MAP
中注释掉 ON_NOTIFY_REFLECT,那么我的对话框的方法就会被调用!?!
为什么通知不能同时到我的控件和我的对话框?!?
最佳答案
ON_NOTIFY_REFLECT
覆盖 ON_NOTIFY
,但您可以使用 ON_NOTIFY_REFLECT_EX
代替,它让您的回调决定消息是否应该传递给父级.
参见 Message Reflection for Windows Controls更详细的解释:
If, in your parent window class, you supply a handler for a specific WM_NOTIFY message or a range of WM_NOTIFY messages, your handler will be called only if the child control sending those messages does not have a reflected message handler through ON_NOTIFY_REFLECT(). If you use ON_NOTIFY_REFLECT_EX() in your message map, your message handler may or may not allow the parent window to handle the message. If the handler returns FALSE, the message will be handled by the parent as well, while a call that returns TRUE does not allow the parent to handle it. Note that the reflected message is handled before the notification message.
关于c++ - 当我有控件定义的 ON_NOTIFY_REFLECT 时,ON_NOTIFY 在我的对话框中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27325358/
我正在尝试将 LVN_ ITEMCHANGED 发布到我的自定义网格列表的所有者。我知道如何使用 PostMessage 发送 WM_User 消息(如此处所示) ::PostMessage( Afx
我总是很难将所有这些宏记在脑海中。是否有一种简单的方法来记住它们,以及在给定场景中使用哪些? 具体来说,其中一个是否允许对话框拦截/检测到子控制窗口的消息?例如,当 IDC_MY_CONTROL 收到
在我的 CTreeCtrl 派生类中,我作用于 TVN_ITEMEXPANDED: ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, &OnTVNItemExpanded) 在控
我是一名优秀的程序员,十分优秀!