Bladeren bron

Need to call UpdateExplicitBounds here too. Fixes [akRight, akBottom] controls such as DirBrowseButton which are moved/resized at run time, then moved again when WizardSizePercent is used, but then moved back by VCL when FlipControls does the Anchors update.

Martijn Laan 6 jaren geleden
bovenliggende
commit
90f9181127
2 gewijzigde bestanden met toevoegingen van 11 en 4 verwijderingen
  1. 10 1
      Components/BidiUtils.pas
  2. 1 3
      Projects/SetupForm.pas

+ 10 - 1
Components/BidiUtils.pas

@@ -61,6 +61,9 @@ begin
     AParams.ExStyle := AParams.ExStyle or (WS_EX_RTLREADING or WS_EX_LEFTSCROLLBAR or WS_EX_RIGHT);
 end;
 
+type
+  TControlAccess = class(TControl);
+
 procedure FlipControls(const AParentCtl: TWinControl);
 var
   ParentWidth, I: Integer;
@@ -75,8 +78,14 @@ begin
       Ctl := AParentCtl.Controls[I];
       if (akLeft in Ctl.Anchors) and not (akRight in Ctl.Anchors) then
         Ctl.Anchors := Ctl.Anchors - [akLeft] + [akRight]
-      else if not (akLeft in Ctl.Anchors) and (akRight in Ctl.Anchors) then
+      else if not (akLeft in Ctl.Anchors) and (akRight in Ctl.Anchors) then begin
+        { Before we can set Anchors to [akLeft, akTop] (which has a special
+          'no anchors' meaning to VCL), we first need to update the Explicit*
+          properties so the control doesn't get moved back to an old position. }
+        if Ctl.Anchors = [akTop, akRight] then
+          TControlAccess(Ctl).UpdateExplicitBounds;
         Ctl.Anchors := Ctl.Anchors - [akRight] + [akLeft];
+      end;
       Ctl.Left := ParentWidth - Ctl.Width - Ctl.Left;
     end;
   finally

+ 1 - 3
Projects/SetupForm.pas

@@ -254,9 +254,7 @@ begin
     AnchorsList.Add(Ctl, Ctl.Anchors);
     { Before we can set Anchors to [akLeft, akTop] (which has a special
       'no anchors' meaning to VCL), we first need to update the Explicit*
-      properties so the control doesn't get moved back to an old position.
-      Actually only needed if a resize is done in the IDE without removing
-      all Explicit* properties from the DFM. }
+      properties so the control doesn't get moved back to an old position. }
     TControlAccess(Ctl).UpdateExplicitBounds;
     Ctl.Anchors := [akLeft, akTop];
   end;