[Lazarus] LCL Message handling
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Wed Oct 19 14:52:54 CEST 2011
Felipe Monteiro de Carvalho schrieb:
> On Wed, Oct 19, 2011 at 1:56 PM, Hans-Peter Diettrich
> <DrDiettrich1 at aol.com> wrote:
>> Can somebody explain the purpose of e.g. WindowProc, WndProc and
>> MainWndProc, in the LCL?
>
> Delphi compatibility. AFAIK WndProc works for messages >= WM_USER
WndProc can preprocess *any* kind of messages, which must be handled in
a non-standard way in a specific control, e.g. the TripleClick messages.
WndProc finally calls Dispatch, to invoke the implemented message
handler of the control, or DefaultHandler for all messages without
assigned handlers.
>> In Delphi MainWndProc calls the handler assigned to WindowProc, enclosed in
>> try-finally and try-except blocks. WindowProc typically is initialized with
>> WndProc. Why is this implemented differently in the LCL, and how?
>
> I remember that some people did not like how this worked in Delphi so
> it didn't work like that, then we had a define to pass messages >=
> WM_USER to WndProc. I think the define later got changed into always
> active. I don't remember anyone asking for messages < WM_USER, so
> probably till now they are not passed to WndProc. I'm just typing from
> memory, so I could be wrong in parts of this.
I fear that Delphi compatibility is broken, when MainWndProc does
nothing. When it is not removed, it should do what Delphi does, so that
it can be used in code ported from Delphi. Otherwise it should be
removed, together with WindowProc, so that every attempt to use it will
result in compiler errors.
I also don't understand the parallel or different WM..., LM..., CM...
and CN... message IDs. Is that separation related to messages handled
(or not handled) by widgets or by the LCL? Or have the LM... message IDs
been added only to prevent cyclic unit references?
DoDi
More information about the Lazarus
mailing list