[lazarus] Bug in TControl.ChangeBounds?

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Aug 4 04:15:59 EDT 2003


On Sun, 03 Aug 2003 19:53:17 -0300
Karl Brandt <pascalive at bol.com.br> wrote:

> Looking at the mentioned function i noticed that  FLastChangeboundRect 
> stores the width and height in Right and Bottom fields but is tested as 
> if was storing the bottom-right coordinates.
> 
>    ARight:=ALeft+AWidth;
>    ABottom:=ATop+AHeight;
>    if (ALeft=FLastChangeboundRect.Left)
>    and (ATop=FLastChangeboundRect.Top)
>    and (ARight=FLastChangeboundRect.Right)
>    and (ABottom=FLastChangeboundRect.Bottom)
>    then exit;
>    FLastChangeboundRect:=Rect(ALeft,ATop,AWidth,AHeight);

Strange, that this was not spottet earlier.


> I would change the above code to
> 
>    //removes ARight and ABottom variables
>    if (ALeft=FLastChangeboundRect.Left)
>    and (ATop=FLastChangeboundRect.Top)
>    and (AWidth=FLastChangeboundRect.Right)
>    and (AHeight=FLastChangeboundRect.Bottom)
>    then exit;
>    FLastChangeboundRect:=Rect(ALeft,ATop,AWidth,AHeight);
> 
> and not just changing
> 
>   FLastChangeboundRect:=Rect(ALeft,ATop,AWidth,AHeight);
> to
>   FLastChangeboundRect:=Bounds(ALeft,ATop,AWidth,AHeight);
> 
> the first looks cleaner
> i also would rename FLastChangeboundRect to FLastChangeRect
> 
> but it's just a suggestion

It should store the rect of the last ChangeBounds call, so maybe
FLastChangeBounds is even better.


Mattias






More information about the Lazarus mailing list