[Lazarus] SendMessage Bug Work Around.

Michael Schnell mschnell at lumino.de
Fri Apr 23 11:09:35 CEST 2010


On 04/22/2010 06:34 PM, José Mejuto wrote:
> So, LCL.SendMessage is a compatibility layer that transform the
> windows message style in an operation over the current widgetset. In
> GTK a message like WM_SHOW will be "converted" in a sequence of GTK
> operations to show or hide a window/control. This way inside an
> application there is (or better should not be) any difference to the
> application running in Windows, GTK, etc...
>   
I don't see why, in Windows, anybody should use SendMessage to send a
message top a window that is assigned to the same process. AFAIK, this
is what PostMessage (as well the VCL/LCL function as the Windows API
call) is provided for.
> Of course maybe is reasonable to allow plain SendMessage
> (LCL.SendMessage) to send a plain (whichever) message when the target
> is not an LCL handle :-? in Windows platform, 
>   

I don't see why. in Delphi VCL, Lazarus Windows LCL and any program done
with the Windows API in mind you would use PostMessage here. And thus
for compatibility reasons, PostMessage is provided in a platform
independent way by the LCL and decently implemented e.g. with the GTK2
interface (aka "Widget Type") (the NOGUI Widget Type just provides a
dummy (as expected), I did not investigate the other Widget types, but I
believe they do provide4 appropriate implementations.)

> but them a lot of posts
> like WM_COPYDATA works in Windows but fails in Linux will fill the
> bugtracker.
>   
Of course as these are either implementation-depending features of the
Widget set or (in the case of WM_COPYDATA) are unrelated to a "Widget
Set" at all and use OS-Depending implementation details. But this does
not explain, why "SendMessage" is provided as an
architecture-independently defined but not at all
architecture-independently implemented LCL function at all. Would it not
appropriate to use PostMessage (or something completely unrelated)
instead of SendMessage in any platform independent code in the LCL (and
with that drop the misleading platform-independent definition) ?

-Michael




More information about the Lazarus mailing list