[Lazarus] Messages unit

patspiper patspiper at gmail.com
Tue Apr 26 15:25:55 CEST 2011


Hi,

Description of Lazarus' Messages unit:
"This unit defines some of the most common definitions of Delphi's 
messages.pas to make porting easy. It is not used by the LCL itself."

It is thus used along with the LMessages unit in converted Delphi 
projects to eliminate the need to change messages from TWxxx to TLxxx 
all over the project. Example:

Delphi code:
procedure TWinControlDecsendant.WMPaint(var Message: TWMPaint);
begin
  PaintHandler(Message);
end;

PaintHandler definition:
TWinControl.PaintHandler(TLMPaint)

Lazarus Messages unit:
TWMPaint = TLMPaint;

The above is exactly what happens under Linux to make things work 
smoothly. However under Windows, FPC's Messages unit takes precedence 
and hides Lazarus' Messages unit.

FPC Messages unit:
TWMPaint = Windows.TWMPaint

and the code is broken as PaintHandler expects TLMPaint as an argument 
but receives Windows.TWMPaint instead.

I suggest renaming and/or aliasing Lazarus' Messages unit as 
WinMessages. Aliasing (2 units using the same include file?) could prove 
to be a good solution as it does not disrupt old code.

Thoughts?

Stephano




More information about the Lazarus mailing list