窗口之间传递的消息 [英] message passing between windows

查看:94
本文介绍了窗口之间传递的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是一个初学者.我知道c,c ++语言.我想为两个窗口之间的消息传递编写代码.建议我一些用Visual c ++编写上述应用程序所需的链接和东西.
在此先感谢


I am a beginer.I know c,c++ languages. I want to write code for message passing between two windows. suggest me some links and stuff required for writing the above application in visual c++.
Thanks in advance

推荐答案

我建​​议您阅读有关 SendMessage [ PostMessage [窗口过程 [
I recomment you read about messaging[^] in MSDN for starters, Reading about SendMessage[^] and PostMessage[^] is also a good idea, learning the difference between the two. Window Procedures[^] is also a topic you might require.

I hope these can help you get started.


正如已经建议的,您应该阅读PostMessage的文档(我不会使用SendMessage与其他应用程序进行通信).您还应该查看 RegisterWindowMessage [
As already suggested, you should read the documentation of PostMessage (I wouldn''t use SendMessage for communicating with another application). You should also have a look at RegisterWindowMessage[^] function documentation.


其他人建议使用PostMessage 将数据从一个应用程序获取到另一个应用程序.方便发布的消息是WM_COPYDATA ,因为它可以将一个过程中的任意数据块携带到另一个过程中.这意味着您可以以相当广泛的方式在两个应用之间设计自己的协议.

如果您要编写要在Vista或更高版本的Windows上运行的代码,则可能还需要与ChangeWindowMessageFilterEx()搏斗. Vista在很多情况下会在应用程序之间过滤WM_COPYDATA 消息,您必须明确地说"Oi,我想收到该消息,bozo!"

您可能要尝试的其他方法包括内存映射文件(有效地在进程之间共享内存-再次,在Vista和更高版本上要难一些),命名管道或套接字(如果比其他选项要慢,则非常可移植).

哦,然后是RPC(远程过程调用),COM(组件对象模型),CORBA(如COM,但我不记得首字母缩写的含义-通用对象请求代理敲响了钟声)和Java RMI之类的东西(如果您不使用Java,则没有用).

我个人从插座开始,因为它们是便携式的,并且可以在地球上几乎任何两个应用程序之间使用.与RPC等相比,它们也相对容易编程,并且网上有很多不错的教科书和示例代码.

干杯,

Other people have suggested using PostMessage to get data from one app to another. A handy message to post is WM_COPYDATA as it can carry an arbitrary lump of data from one process to another. This means you can design your own protocol between two apps in a fairly broad way.

If you''re writing your code to run on Vista or later versions of windows you might also have to wrestle with ChangeWindowMessageFilterEx(). Vista filters out WM_COPYDATA messages between apps in a lot of cases and you have to explicitly say "Oi, I want to receive that message, bozo!"

Other ways you might like to try include memory mapped files (effectively shared memory between processes - again, it''s a bit harder on Vista and later), named pipes or sockets (very portable if slower than other options).

Oh, and then there''s RPC (remote procedure calls), COM (component object model), CORBA (like COM but with I can never remember what the acronym means - common object request broker rings a bell) and things like Java RMI (bit useless if you''re not using Java).

Personally I''d start with sockets as they''re portable and can be used between just about any two applications on the planet. They''re also relatively easy to program compared to RPC and the like AND there''s plenty of good textbooks around and example code on the net.

Cheers,

Ash


这篇关于窗口之间传递的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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