I wish to post a message to a thread. If i'm not wrong i should use the
PostThreadMessage and GetMessage. However, i can not grab the message from
the thread's message queue. Can anybody gimme some hint where i did wrong?
Thanks in advance. =)
Here is my code snippet
procedure TTestThread.Execute;
var
msgMine: MSG;
begin
while not terminated do
begin
GetMessage(msgMine, ThreadID, 0, 0);
if msgMine.message = CSM_TEST then
Form1.Label1.Caption := IntToStr(msgMine.wParam);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
PostThreadMessage(thA.ThreadID, CSM_TEST, 1234, 0);
end;
From,
Hon Yuen, Ng
The second parameter must be a window handle. Window handles and thread
IDs are *not* the same.
To retreive messages posted with PostThreadMessage, you must specify
zero for the window handle. The last three parameters will all be zero,
in your case.
> if msgMine.message = CSM_TEST then
> Form1.Label1.Caption := IntToStr(msgMine.wParam);
Never ever use a line like that above. Do not modify VCL components from
other threads, only from the main thread.
--
Rob
"Rob Kennedy" <rken...@cs.wisc.edu> wrote in message
news:3ede...@newsgroups.borland.com...