unit Unitxx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Const WM_MyMSG=WM_USER+1003;
type
my = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure onmymsg(var message:TMessage);message WM_MyMSG;
public
{ Public declarations }
end;
var
Form1: TForm1;
var
m1:dword;
implementation
{$R *.dfm}
procedure TForm1.onmymsg(var message: TMessage);
begin
showmessage('123');
end;
procedure TForm1.Button1Click(Sender: TObject);
var m:my;
begin
m:=my.Create(false);
m.FreeOnTerminate:=true;
sendmessage(m1,WM_MyMSG,0,0);
end;
{ my }
procedure my.Execute;
begin
inherited;
sendmessage(form1.Handle,WM_MyMSG,0,0);
end;
end.
//贴代码了事