[Lazarus] Inconsistent ScrolledClientRect calculation

Hans-Peter Diettrich DrDiettrich1 at aol.com
Fri Oct 7 06:34:05 CEST 2011


TControl.ScrolledClientRect offsets *all* fields in the TRect by the 
scroll offsets. This is *incorrect*, when the TRect is initialized to 
ClientRect, where the second set of coordinates is the Width and Heigth, 
not the BottomRight corner of the area. Obviously Width and Height are 
insensitive to scrolling!

The ambiguous use of TRect, with either BottomRight or WidthHeight in 
the second TPoint, often leads to misunderstandings and flawed code (as 
above). It were helpful when type alias would be introduced and used, or 
when the argument names would indicate the current content of an TRect.

E.g. in the EasyDockManager I use XYWH or TLBR for the argument names, 
to clarify the content of the passed TRect.

DoDi





More information about the Lazarus mailing list