我定义了一个消息const WM_IEC103=WM_User+$1000;然后给一个form发送消息procedure TForm1.Button1Click(Sender: TObject);
var
hd: THandle;
InfoNum:integer;
begin
hd := FindWindow('TForm_103Communicate',nil);
if hd <> 0 then
sendmessage(hd,WM_IEC103,5,0);
end;在TForm_103Communicate中,我定义了一个接收函数
procedure TForm_103Communicate.Commnunicate(var msg:Tmessage);
var Data_Main103:TData_103;
i:integer;
begin
if Tmessage(msg).Msg=WM_IEC103 then
showmessage('haha');
end;然后用Timer来调用Commnunicate
procedure TForm_103Communicate.Timer1Timer(Sender: TObject);
begin
Commnunicate(msg);//msg是一个全局变量在public中定义
end;为什么接受不到这个消息呢?
var
hd: THandle;
InfoNum:integer;
begin
hd := FindWindow('TForm_103Communicate',nil);
if hd <> 0 then
sendmessage(hd,WM_IEC103,5,0);
end;在TForm_103Communicate中,我定义了一个接收函数
procedure TForm_103Communicate.Commnunicate(var msg:Tmessage);
var Data_Main103:TData_103;
i:integer;
begin
if Tmessage(msg).Msg=WM_IEC103 then
showmessage('haha');
end;然后用Timer来调用Commnunicate
procedure TForm_103Communicate.Timer1Timer(Sender: TObject);
begin
Commnunicate(msg);//msg是一个全局变量在public中定义
end;为什么接受不到这个消息呢?
WM_IEC103 = WM_USER + $1000;type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMIEC103(var Msg: TMessage); message WM_IEC103;
public
{ Public declarations }
end;//....procedure TForm1.WMIEC103(var Msg: TMessage);
begin
Caption := Format('%.6f', [Now]);
end;
begin
showmessage('haha');
nnd;