将消息传递到另一个窗口
我想编写一个应用程序,将收到的每条消息传递到另一个窗口。例如,我有一个应用程序,用户可以在其中按某些键、将鼠标移到其上等,并且我希望将所有这些消息传递给例如 MS Paint。
我该怎么做?有什么想法吗?据我所知,将击键发送到另一个窗口可能存在问题,还请指教。
编辑
好的,也许我会给你更多关于我正在寻找的内容的描述。
我的应用程序在表单上显示另一个应用程序的窗口。现在我想使用发送到我的应用程序表单的消息(如按键、鼠标移动等)来控制另一个窗口。
我一直在考虑将我的表单收到的所有消息传递到我“嵌入”到我自己的应用程序的窗口中。我所说的“嵌入”是指使应用程序窗口显示在我的表单上。
也许我的问题还有另一种解决方案。请指教。
感谢您抽出时间。
I would like to write an application which passes every message it receives to another window. For example, I have an application where user can press some keys, move mouse over it, etc. and I want all these messages passed to, for example, MS Paint.
How do I do this? Any ideas? As far as I know, there may be a problem with sending key strokes to another window, so please advice as well.
EDIT
Okay, maybe I will give you more description of what I'm looking for.
My applications displays a window of another application on the form. Now I would like to control the other window using messages sent to my application's form (like key downs, mouse moves, etc.).
I have been thinking of passing all the messages my form receives to the window of the application I'm kind of 'embedding' into my own. By 'embedding' I mean making the application window display on my form.
Maybe there's another solution to my problem. Please advice.
Thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一些消息(即输入消息)通过消息队列到达,其余消息直接传送到接收窗口。因此,您要求执行的操作要求您执行以下所有操作:
我无法想象这真的能解决你的问题,无论问题是什么。
Some messages (i.e. input messages) arrive through the message queue and the rest are delivered straight to the recipient windows. What you are asking to do therefore requires you to do all of the following:
I can't imagine that this is really going to be the solution to your problem, whatever that problem is.
转发消息绝对是可能且容易的,但它可能不会达到您的预期。请查看此处。
Forwarding the messages is definitely possible and easy, but it likely won't do what you are expecting. Take a look here.
覆盖表单的 DefaultHandler() 并将其获取的每条消息发布到另一个表单。如果表单甚至某些控件中有任何显式消息处理程序,那么您可能在 DefaultHandler() 中看不到这些消息。
Override the form's DefaultHandler() and post every message it gets to the other form. If there are any explicit message handlers in the form or even some controls then you may not see those messages in DefaultHandler().