Sign in Join

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

Mailing lists / lazarus / 2017-09

TControl.ChangeScale impl

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Alexey

There is such procedure. why not to rewrite it via call to AutoAdjustLayout. to not have "dup" code.

procedure TControl.ChangeScale(Multiplier, Divider: Integer);
var
   R: TRect;
begin
   if Multiplier  Divider then
   begin
     ScaleConstraints(Multiplier, Divider);
     if not ParentFont then
       Font.Height := MulDiv(GetFontData(Font.Reference.Handle).Height,
Multiplier, Divider);
     R := BaseBounds;
     if (Self is TCustomForm) and (GetParentForm(Self, True) = Self) then
     begin
       //Dont change Left,Top if this is the topmost form
       R.Right := R.Left + MulDiv(R.Right-R.Left, Multiplier, Divider);
       R.Bottom := R.Top + MulDiv(R.Bottom-R.Top, Multiplier, Divider);
     end
     else
     begin
       R.Left := MulDiv(R.Left, Multiplier, Divider);
       R.Top := MulDiv(R.Top, Multiplier, Divider);
       R.Right := MulDiv(R.Right, Multiplier, Divider);
       R.Bottom := MulDiv(R.Bottom, Multiplier, Divider);
     end;
     BoundsRect := R;
   end;
end;
Regards, Alexey

Reply by email