//给你一个我写的例子
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
WM_MYMSG=WM_USER+10; //定义自己的消息常量
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure GetMyMessage(var msg:TMessage);message WM_MYMSG;//定义捕捉自己的消息的过程
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.GetMyMessage(var msg:TMessage);
begin
ShowMessage('得到我的消息了!');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//发送自己定义的消息
Sendmessage(handle,WM_MYMSG,0,0);
end;
end.