给你一个简单的例子吧<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br>const MY_MSG=WM_USER+100; //先自己定义一个自己的消息<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> procedure MYMSG(var Msg:TMsg);message MY_MSG; //注意格式<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> SendMessage(Handle,MY_MSG,0,0); //调用sendmessage来发送你自定义的的消息<br>end;<br>procedure TForm1.MYMSG(var MSG:TMsg); //响应消息事件<br>begin<br> ShowMessage('Test');<br>end;<br><br>end.<br>