有没有在多个dll之间发送接收消息的例子(100分)

  • 主题发起人 主题发起人 cbypony
  • 开始时间 开始时间
C

cbypony

Unregistered / Unconfirmed
GUEST, unregistred user!
在一个dll中发送一个结构struct给另一个dll的一个窗体,然后另一个dll接收到这个消息后<br>分析这个结构的数据
 
在一个dll的窗体中发出消息中,另一个dll中的窗体怎么知道有消息来了呢?
 
已实现,下面是在一个窗体中发送接收消息的例子,两个应用程序间也一样,把自定议的消息常量定义到一个公共头文件就可以了<br>unit Unit3;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls;<br>const WM_MYMESSAGE=WM_USER+100;<br>WM_MYMESSAGE2 = WM_USER+200;<br>type<br>&nbsp; TForm3 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; Button3: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button3Click(Sender: TObject);<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; procedure appmessage(var msg:TMessage);message WM_MYMESSAGE;<br>&nbsp; &nbsp; procedure appmessage2(var msg:TMessage);message WM_MYMESSAGE2;<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form3: TForm3;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm3.Button1Click(Sender: TObject);<br>begin<br>&nbsp; postmessage(handle,WM_MYMESSAGE,1,0);<br><br>end;<br><br><br><br>procedure TForm3.appmessage(var msg:TMessage);<br>begin<br>&nbsp; showmessage(inttostr(msg.WParam));<br>end;<br><br>procedure TForm3.appmessage2(var msg:TMessage);<br>begin<br>&nbsp; showmessage(inttostr(msg.WParam));<br>end;<br><br>procedure TForm3.Button3Click(Sender: TObject);<br>begin<br>&nbsp; postmessage(handle,WM_MYMESSAGE2,2,0);<br>end;<br><br>end.
 
你在网上找WM_COPYDATA就可以找到很多这样的例子![:)]
 
后退
顶部