View Issue Details

IDProjectCategoryView StatusLast Update
0026654LazarusLCLpublic2014-08-31 15:53
ReporterZeljan RikaloAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3 (SVN)Product Build 
Target VersionFixed in Version1.2.6 
Summary0026654: LCL: ScaleBy() does not work correct
DescriptionAccording to embarcadero docs http://docwiki.embarcadero.com/Libraries/XE6/en/Vcl.Controls.TWinControl.ScaleBy left & top should be untouched.
LCL moves TCustomForm left & top and that's not correct (if Position = poDesigned. Left & Top of TCustomForm should be left untouched in case of top level form if position = poDesigned or poDefault, other positions should be recalculated since current position does not work ok (eg. Position = poScreenCenter should not move form to the center after scaling).
TagsNo tags attached.
Fixed in Revisionr46092
LazTarget-
WidgetsetGTK 2, Win32/Win64, Carbon, Cocoa, QT
Attached Files
  • scaleby.diff (1,153 bytes)
    Index: lcl/include/control.inc
    ===================================================================
    --- lcl/include/control.inc	(revision 46073)
    +++ lcl/include/control.inc	(working copy)
    @@ -773,10 +773,19 @@
         if not ParentFont then
           Font.Height := MulDiv(GetFontData(Font.Reference.Handle).Height, Multiplier, Divider);
         R := BaseBounds;
    -    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);
    +    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;
    
    scaleby.diff (1,153 bytes)

Activities

Bart Broersma

2014-08-30 15:22

developer  

scaleby.diff (1,153 bytes)
Index: lcl/include/control.inc
===================================================================
--- lcl/include/control.inc	(revision 46073)
+++ lcl/include/control.inc	(working copy)
@@ -773,10 +773,19 @@
     if not ParentFont then
       Font.Height := MulDiv(GetFontData(Font.Reference.Handle).Height, Multiplier, Divider);
     R := BaseBounds;
-    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);
+    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;
scaleby.diff (1,153 bytes)

Bart Broersma

2014-08-30 15:23

developer   ~0076790

Last edited: 2014-08-30 15:23

View 2 revisions

Possible patch attached.
Not sure if this is the right approach, so I did not commit it.

Note: on Delphi 7 ScaleBy does not seem to alter the size of the form at all.

Zeljan Rikalo

2014-08-30 16:26

developer   ~0076792

Then it's bug in Delphi 7, since there's ScaleControls() which scales all controls inside form but not form itself.
IMO, ScaleBy() works correct in LCL except that Left & Top should be left unchanged , or it can be changed only in case of poScreenCenter, poMainFormCenter and similar. Anyway, according to the embarcardero docs your patch fixes the problem.

Bart Broersma

2014-08-30 23:32

developer   ~0076797

OK, commited.
Please close if OK.

Zeljan Rikalo

2014-08-31 15:53

developer   ~0076805

Thanks.

Issue History

Date Modified Username Field Change
2014-08-30 11:51 Zeljan Rikalo New Issue
2014-08-30 15:22 Bart Broersma File Added: scaleby.diff
2014-08-30 15:23 Bart Broersma Note Added: 0076790
2014-08-30 15:23 Bart Broersma Status new => confirmed
2014-08-30 15:23 Bart Broersma Note Edited: 0076790 View Revisions
2014-08-30 16:26 Zeljan Rikalo Note Added: 0076792
2014-08-30 23:32 Bart Broersma Fixed in Revision => r46092
2014-08-30 23:32 Bart Broersma Note Added: 0076797
2014-08-30 23:32 Bart Broersma Status confirmed => resolved
2014-08-30 23:32 Bart Broersma Resolution open => fixed
2014-08-30 23:32 Bart Broersma Assigned To => Bart Broersma
2014-08-30 23:33 Bart Broersma Fixed in Version => 1.2.6
2014-08-31 15:53 Zeljan Rikalo Note Added: 0076805
2014-08-31 15:53 Zeljan Rikalo Status resolved => closed