[Lazarus] LCL messaging system SendMessage and Multi-Threads

Michael Schnell mschnell at lumino.de
Fri May 7 10:41:56 CEST 2010


On 05/07/2010 05:49 AM, Andrew Brunner wrote:

in Linux, SendMessage seems to be implemented in a way that is not very
compatible to what SendMessage does in Windows. (No wonder: SendMessage
is a quite "interesting" Windows API function, that provides lots of
side-effects: sometimes it blocks until the tasks is done. sometimes it
interprets the parameters given and even transfers memory chunks from
one applications to another.)

OTOH, PostMessage is defined to be non-blocking and works just within a
single (multi-threaded) application. This seems to be provided by the
LCLs "GTK2 Widget Type" in a very Windows compatible way. So you can use
this to notify the main thread from a worker thread.

In the main Form you define an appropriate  class procedure by 
"procedure() .... message" and same will be called in the main thread if
in some thread you do a postmessage() with the main form's handle and
the  appropriate message number. Here you can do things like "visible :=
true".

-Michael




More information about the Lazarus mailing list