1
13708782004
Unregistered / Unconfirmed
GUEST, unregistred user!
发送方:
const wm_login = wm_user + 1000;
type
pmymsg = ^tmymsg;
tmymsg = record
msg: cardinal;
msgtext: shortstring;
end;
procedure TForm1.Button3Click(Sender: TObject);
var msg: tmymsg;
h: hwnd;
begin
msg.msg := wm_login;
msg.msgtext := 'USERID:516 PWD:123';
h := findwindow(0, 'Form1abc');
if h > 0 then
begin
memo1.Lines.Add('已经找到对方,并且已经发送消息');
SendMessage(h, wm_login, Integer(@msg), 0);
end;
end;
接收方:
const wm_login = wm_user + 1000;
pmymsg = ^tmymsg;
tmymsg = record
msg: cardinal;
msgtext: shortstring;
end;
TForm1 = class(TForm)
Memo1: TMemo;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
public
procedure WndProc(var message: TMessage); override;
end;
procedure TForm1.WndProc(var message: TMessage);
var datamymsg;
begin
if message.Msg = wm_login then
begin
memo1.Lines.Add('aaaaaa');
data := pmymsg(message.wParam);
memo1.Lines.Add(data^.msgtext);
end;
inherited WndProc(message);
end;
//-------为什么,能收到指定消息,但msgtext 部分是空的,或则乱码啊!
const wm_login = wm_user + 1000;
type
pmymsg = ^tmymsg;
tmymsg = record
msg: cardinal;
msgtext: shortstring;
end;
procedure TForm1.Button3Click(Sender: TObject);
var msg: tmymsg;
h: hwnd;
begin
msg.msg := wm_login;
msg.msgtext := 'USERID:516 PWD:123';
h := findwindow(0, 'Form1abc');
if h > 0 then
begin
memo1.Lines.Add('已经找到对方,并且已经发送消息');
SendMessage(h, wm_login, Integer(@msg), 0);
end;
end;
接收方:
const wm_login = wm_user + 1000;
pmymsg = ^tmymsg;
tmymsg = record
msg: cardinal;
msgtext: shortstring;
end;
TForm1 = class(TForm)
Memo1: TMemo;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
public
procedure WndProc(var message: TMessage); override;
end;
procedure TForm1.WndProc(var message: TMessage);
var datamymsg;
begin
if message.Msg = wm_login then
begin
memo1.Lines.Add('aaaaaa');
data := pmymsg(message.wParam);
memo1.Lines.Add(data^.msgtext);
end;
inherited WndProc(message);
end;
//-------为什么,能收到指定消息,但msgtext 部分是空的,或则乱码啊!