[lazarus] Bug in TControl.ChangeBounds?

Karl Brandt pascalive at bol.com.br
Sun Aug 3 18:22:58 EDT 2003


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);

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

karl






More information about the Lazarus mailing list