فهرست منبع

Make sure we don't realign the outer pages too early (before InitializeFont is called). Think this got triggered by the HandledNeeded calls.

Also avoids doing any unneeded realigning when the window size isn't actually changing, making sure we don't interfere with existing scripts which might do odd things like changing WizardBitmapImage.Align to alClient - see recent ng post.

Using alCustom on the controls and TWizardForm.OnAlignPosition instead of OnResize might also work and be cleaner but didn't try.

PS: I really dislike this kind of VCL programming...
Martijn Laan 6 سال پیش
والد
کامیت
d6a9c742b7
2فایلهای تغییر یافته به همراه49 افزوده شده و 37 حذف شده
  1. 0 1
      Projects/Wizard.dfm
  2. 49 36
      Projects/Wizard.pas

+ 0 - 1
Projects/Wizard.dfm

@@ -15,7 +15,6 @@ object WizardForm: TWizardForm
   OldCreateOrder = True
   Scaled = False
   OnClose = FormClose
-  OnResize = FormResize
   DesignSize = (
     497
     360)

+ 49 - 36
Projects/Wizard.pas

@@ -169,7 +169,6 @@ type
     procedure UserInfoEditChange(Sender: TObject);
     procedure DirBrowseButtonClick(Sender: TObject);
     procedure GroupBrowseButtonClick(Sender: TObject);
-    procedure FormResize(Sender: TObject);
   private
     { Private declarations }
     FPageList: TList;
@@ -186,10 +185,12 @@ type
     DoneWithWizard: Boolean;
     PrepareToInstallNeedsRestart: Boolean;
     procedure AdjustFocus;
+    procedure AnchorOuterPagesOnResize(Sender: TObject);
     procedure CalcCurrentComponentsSpace;
     procedure ChangeReadyLabel(const S: String);
     function CheckSerialOk: Boolean;
     procedure CreateTaskButtons(const SelectedComponents: TStringList);
+    procedure EnableAnchorOuterPagesOnResize;
     procedure FindPreviousData;
     function GetPreviousPageID: Integer;
     function PrepareToInstall(const WizardComponents, WizardTasks: TStringList): String;
@@ -767,6 +768,7 @@ begin
     ClientWidth := SaveClientWidth;
     ClientHeight := SaveClientHeight;
     if shWizardResizable in SetupHeader.Options then begin
+      EnableAnchorOuterPagesOnResize;
       { Do not allow user to resize it smaller than the current size. }
       Constraints.MinHeight := Height;
       Constraints.MinWidth := Width;
@@ -1165,13 +1167,55 @@ begin
     NoIconsCheck.Visible := False;
 end;
 
+procedure TWizardForm.AnchorOuterPagesOnResize(Sender: TObject);
+
+  procedure AnchorOuterPage(const Page: TNewNotebookPage;
+    const BitmapImage: TBitmapImage);
+  var
+    Ctl: TControl;
+    I, NewLeft, NewWidth: Integer;
+  begin
+    if BaseUnitX = 0 then
+      InternalError('AnchorOuterPage: BaseUnitX = 0');
+
+    NewWidth := MulDiv(BitmapImage.Height, 164, 314);
+    if ControlsFlipped then
+      BitmapImage.Left := ClientWidth - NewWidth;
+    BitmapImage.Width := NewWidth;
+    for I := 0 to Page.ControlCount-1 do begin
+      Ctl := Page.Controls[I];
+      if Ctl <> BitmapImage then begin
+        NewLeft := BitmapImage.Width + ScalePixelsX(12); // 12 is space between bitmap and controls
+        Ctl.Width := ClientWidth - ScalePixelsX(20) - NewLeft; //20 is space between controls and right border
+        if not ControlsFlipped then
+          Ctl.Left := NewLeft;
+      end;
+    end;
+  end;
+
+begin
+  { WizardBitmapImage(2)'s size is already corrected by the Anchors property but
+    this doesn't keep the aspect ratio. Calculate and set new width to restore
+    the aspect ratio and update all the other controls in the page for this. }
+  AnchorOuterPage(WelcomePage, WizardBitmapImage);
+  AnchorOuterPage(FinishedPage, WizardBitmapImage2);
+end;
+
+procedure TWizardForm.EnableAnchorOuterPagesOnResize;
+begin
+  OnResize := AnchorOuterPagesOnResize;
+end;
+
 procedure TWizardForm.SizeAndCenter;
 begin
   { Apply custom initial size from script }
-  if SetupHeader.WizardSizePercentX > 100 then
-    ClientWidth := MulDiv(ClientWidth, SetupHeader.WizardSizePercentX, 100);
-  if SetupHeader.WizardSizePercentY > 100 then
-    ClientHeight := MulDiv(ClientHeight, SetupHeader.WizardSizePercentY, 100);
+  if (SetupHeader.WizardSizePercentX > 100) or (SetupHeader.WizardSizePercentY > 100) then begin
+    EnableAnchorOuterPagesOnResize;
+    if SetupHeader.WizardSizePercentX > 100 then
+      ClientWidth := MulDiv(ClientWidth, SetupHeader.WizardSizePercentX, 100);
+    if SetupHeader.WizardSizePercentY > 100 then
+      ClientHeight := MulDiv(ClientHeight, SetupHeader.WizardSizePercentY, 100);
+  end;
 
   { Center }
   if shWindowVisible in SetupHeader.Options then
@@ -2401,37 +2445,6 @@ begin
   Action := caNone;
 end;
 
-procedure TWizardForm.FormResize(Sender: TObject);
-
-  procedure AnchorOuterPage(const Page: TNewNotebookPage;
-    const BitmapImage: TBitmapImage);
-  var
-    Ctl: TControl;
-    I, NewLeft, NewWidth: Integer;
-  begin
-    NewWidth := MulDiv(BitmapImage.Height, 164, 314);
-    if ControlsFlipped then
-      BitmapImage.Left := ClientWidth - NewWidth;
-    BitmapImage.Width := NewWidth;
-    for I := 0 to Page.ControlCount-1 do begin
-      Ctl := Page.Controls[I];
-      if Ctl <> BitmapImage then begin
-        NewLeft := BitmapImage.Width + ScalePixelsX(12); // 12 is space between bitmap and controls
-        Ctl.Width := ClientWidth - ScalePixelsX(20) - NewLeft; //20 is space between controls and right border
-        if not ControlsFlipped then
-          Ctl.Left := NewLeft;
-      end;
-    end;
-  end;
-
-begin
-  { WizardBitmapImage(2)'s size is already corrected by the Anchors property but
-    this doesn't keep the aspect ratio. Calculate and set new width to restore
-    the aspect ratio and update all the other controls in the page for this. }
-  AnchorOuterPage(WelcomePage, WizardBitmapImage);
-  AnchorOuterPage(FinishedPage, WizardBitmapImage2);
-end;
-
 procedure TWizardForm.TypesComboChange(Sender: TObject);
 var
   TypeEntry: PSetupTypeEntry;