postmessage can't work in windows xp/wince ,it's a bug in lazarus
Original Reporter info from Mantis: happy_Lee
-
Reporter name: lee
Original Reporter info from Mantis: happy_Lee
- Reporter name: lee
Description:
I had report "0020852: postmessage can't work ,but sendmessage work well 2011-12-09 10:04",the developer mark it resolved ,but it doesn't resolved at all !
my report:
Lazarus: 0.9.30.2
====================================
Const
my1=WM_USER+100;
private
{ private declarations }
procedure show_1(var MSG: Tmessage);message my1;
procedure TForm1.Button1Click(Sender: TObject);
var
CopyDataStruct: TCopyDataStruct;
size:integer;
begin
Size := Length(edit1.text);
CopyDataStruct.lpData := PChar(edit1.text);
CopyDataStruct.dwData := my1;
CopyDataStruct.cbData := Size;
sendMessage(self.Handle, my1, 0, LPARAM(@CopyDataStruct)); // it's ok
// PostMessage(self.Handle,my1,0,LPARAM(@CopyDataStruct)); // doesn't work
end;
procedure TForm1.show_1(var MSG: Tmessage);
var
cdds : TcopyDataStruct;
begin
cdds := PcopyDataStruct(MSG.LParam)^;
edit2.Text := (Pchar(cdds.lpData));
end;
====================================================================
if use the "sendmessage", "edit2.text" can show the correct text;
if use the "postmessage", "edit2.text" can't show anything;
and next is reply:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ludo Brands (reporter)
2011-12-09 11:33
The problem is that CopyDataStruct is a local var in TForm1.Button1Click and doesn't exist anymore when TForm1.show_1 receives the message sent by postmessage.
sendMessage waits until the message is sent and processed.
--------------------------------------------------------------------------------
Zeljan Rikalo (developer)
2011-12-09 11:47
Misuse of PostMessage().
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Additional information:
I don't think so.
Beacuse it work well in Delphi 7.0
CopyDataStruct has been turn to message,it attach the message,it isn't belong to "var" again .
Maybe it's a bug in Lazarus.
BTW: run in winxp/wince
===============================
Maybe the reporter mark the problem resolve whether or not is good idea.
Mantis conversion info:
- Mantis ID: 20885
- Version: 0.9.30.2