LucieLastic
Programmer
hi
I'm trying to pass a 13 character string to another app using a PostMessage or SendMessage call. I have the same RegisterWindowMessage in each FormCreate. The receiving code just keeps getting a null terminated string. Can anyone help?
Tried all sorts but can't get it to work:
Many thanks in advance
Lou
I'm trying to pass a 13 character string to another app using a PostMessage or SendMessage call. I have the same RegisterWindowMessage in each FormCreate. The receiving code just keeps getting a null terminated string. Can anyone help?
Tried all sorts but can't get it to work:
Code:
//The sending code
procedure TForm1.Button1Click(Sender: TObject);
var pMsg : array[0..12] of char;
Msg : string;
begin
Msg := edMsg.text;
pMsg := 'NEED HELP';
SendMessage(FindWindow('TForm1', 'Recipient'), WMStr, integer(@Msg), 0);
//SendMessage(FindWindow('TForm1', 'Recipient'), WMStr, integer(@pMsg), 0);
end;
Code:
//The receiving code
procedure TForm1.DefaultHandler(var msg);
var smsg : string;
begin
inherited DefaultHandler(Msg);
if (TMessage(msg).msg <> WMStr) then
EXIT;
sMsg := String(Pointer(TMessage(Msg).WParam));
// sMsg := StrPas(Pointer(TMessage(Msg).WParam));
lbMsg.caption := smsg;
end;
Many thanks in advance
Lou