[Lazarus] Sending messages

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Nov 26 11:14:48 CET 2011


Mattias Gaertner schrieb:
> On Fri, 25 Nov 2011 22:57:34 +0100
> Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:
> 
>> zeljko schrieb:
>>> On Friday 25 of November 2011 14:33:16 Hans-Peter Diettrich wrote:
>>>
>>>
>>>  > And how does PostMessage fit into the picture?
>>>
>>>
>>> I'm using PostMessage in an audio application to update position of 
>>> trackbar on mainform from another thread where audio file is loaded and 
>>> playing and it works ok (tested qt and gtk2)
>> This looks like PostMessage is thread-safe, but is not a proof.
> 
> Yes, PostMessage is thread safe.

Thanks.

> The PostMessage function places (posts) a message in the message queue
> and then returns without waiting.

What again raises the question, how many message queues are supported by 
the LCL, and what's required to use them. Until now I suppose that the 
LCL has no platform-independent model for thread message queues, and 
offers TApplication.QueueAsyncCall instead for cross-platform 
applications. Right?


>> I just wonder how a broadcast (to HWND_BROADCAST) works with 
>> SendMessage. But this is a feature that must not be supported for 
>> non-Windows platforms.
> 
> Do you mean "need not"?

Perhaps I meant "must not necessarily...".

Englisch Sprak schwere Sprak ;-)


>>> Qt have similar mechanism: SendEvent() & PostEvent() and it works in 
>>> same way.
>> Are threads supported?
>>
>>
>> The more I try to understand the Lazarus message handling, the more 
>> questions arise :-(
> 
> QT functions are beyond the LCL docs.

Right, but the docs should be valid for *all* platforms. This requires 
to mention cross-platform issues (restrictions...), which affect 
portable applications. What's a method worth, like 
TWidgetset.SystemParameters, when it is only supported on Windows?

It would be nice to get "not implemented" errors or at least "platform 
specific" hints at *compile* time, not only when an application runs on 
a customer's machine.


> The LCL does not support creating windows from other threads.
> You can try doing that by calling the appropriate widget set functions
> yourselves. But I don't know if that will work.
> So, your question is somewhat theoretical, isn't it?

IMO the documentation of the TWidgetset base class is an essential part 
of the Lazarus documentation. It is not only required to understand the 
high-level LCL code, but also is a good place for the documentation of 
the named constants, usable as parameters in many methods across the 
entire LCL.

DoDi





More information about the Lazarus mailing list