如何将子通知传递给主窗口? [英] How to pass child notifications to main window?

查看:79
本文介绍了如何将子通知传递给主窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我想首先感谢所有花时间查看此主题并尝试提供帮助的人。



我有一个主窗口,带有子静态控制(为了进一步讨论,我们将其标记为S1)。那个静态控件是另一个静态控件的父级(为了进一步讨论,我们将它标记为S2)。



两个静态控件都设置了SS_NOTIFY样式,需要做一些事情当用户点击它们时。



我从第一个控件(S1)捕获通知消息没有问题,因为它将消息发送给父节点,在本例中是主窗口。 br />


但是,我不知道如何在主窗口中捕获子静态控件(S2)通知。



是否可以这样做?



或者我需要继承某些东西吗?也许父静态控制(S1)?







我在MS Visual Studio Express 2008中工作,在Windows XP,用C ++编写,使用WIN32 API。



如果需要任何其他信息(源代码或类似的东西),请提出要求,我将非常乐意提供它。

Hello everyone!

I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.

I have a main window, with a child static control ( for further discussion we shall label it as S1 ). That static control is parent to another static control ( for further discussion we shall label it as S2 ).

Both static controls have SS_NOTIFY style set, and need to do something when user clicks on them.

I have no problem catching notification message from first control ( S1 ) since it sends its messages to parent, in this case main window.

However, I don''t know how to catch child static control''s ( S2 ) notifications in main window.

Is it possible to do this?

Or do I need to subclass something? Maybe parent static control ( S1 )?



I work in MS Visual Studio Express 2008, on Windows XP, in C++, using WIN32 API.

If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.

推荐答案

使用Spy ++来捕获发送到你的窗口的消息。这个工具将为您提供消息传递的内部视图,并让您深入了解如何捕获它们。
Use Spy++ to catch the messages going to your windows. This tool will give a you an inside view where the messages are going and will give you insight into how to catch them.


您好,



实际上我认为如果S2的父母是S1,主要的windiiw不会收到来自S2的通知。相反,S1将接收来自S2的通知。



这意味着:

- S1将其通知发送给其父母,即MainWindow

- S2将其通知发送给其父母,即S2。



如果您想在MainWnd中捕获来自S2的通知,那么你也许应该使用例如重定向它们子类化S2。



希望这有帮助



祝你好运,

JK
Hi,

actually I think that if the parent of S2 is S1, the main windiiw shall not receive the notification from S2. Instead, S1 shall receive the notification from S2.

Which meanse that:
- S1 sends its notification to its parent, which is MainWindow
- S2 sends its notification to its parent, which is S2

If you wand to catch notification from S2 in MainWnd as well, you shall perhaps use redirect them by e.g. subclassing S2.

Hope this helps

Best regards,
J. K.


我已经解决了!



我已经将子类化为S1,它就像一个魅力!



帮助的例子来自Richard Simon的书Windows NT Win32 API SuperBible。



对于那些有类似问题的人,只需在他的书中查看函数CallWindowProc()的描述,在最底部你会找到一个简单的例子。
I have solved it!

I have subclassed S1, and it works like a charm!

Example that helped was from Richard Simon''s book " Windows NT Win32 API SuperBible ".

For those with similar problem, just check out description of function CallWindowProc() in his book, and at the very bottom you will find a simple example.


这篇关于如何将子通知传递给主窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆