Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-08

Bug in TControl.ChangeBounds?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner
to Karl Brandt: Looking at the mentioned function i noticed that FLastChangeboundRect stores the width…
Show quoted text 12 lines
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.

Show quoted text 20 lines
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

Reply by email

Karl Brandt

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

Reply by email