将消息传递到另一个窗口

发布于 2024-12-05 19:31:14 字数 401 浏览 0 评论 0原文

我想编写一个应用程序,将收到的每条消息传递到另一个窗口。例如,我有一个应用程序,用户可以在其中按某些键、将鼠标移到其上等,并且我希望将所有这些消息传递给例如 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

掩耳倾听 2024-12-12 19:31:14

一些消息(即输入消息)通过消息队列到达,其余消息直接传送到接收窗口。因此,您要求执行的操作要求您执行以下所有操作:

  1. 实现一个顶级消息循环,从队列中检索消息并将它们发送到其他应用程序。
  2. 重新实现所有模式窗口循环以传递所有消息。
  3. 将进程中所有窗口的窗口过程替换为将所有消息传递到另一个应用程序的窗口过程。
  4. 寻找我没有提到的其他消息到达机会。

我无法想象这真的能解决你的问题,无论问题是什么。

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:

  1. Implement a top level message loop that retrieves messages from the queue and sends them to the other app.
  2. Reimplement all modal window loops to pass all messages on.
  3. Replace the window procedure for all windows in your process with one that passes all messages on to the other app.
  4. Look for other opportunities for messages to arrive that I have not covered.

I can't imagine that this is really going to be the solution to your problem, whatever that problem is.

悟红尘 2024-12-12 19:31:14

转发消息绝对是可能且容易的,但它可能不会达到您的预期。请查看此处

Forwarding the messages is definitely possible and easy, but it likely won't do what you are expecting. Take a look here.

苏大泽ㄣ 2024-12-12 19:31:14

覆盖表单的 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().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文