Prechádzať zdrojové kódy

TSetupForm: Override ShowModal to add HandleNeeded call. Works around VCL issue.

Jordan Russell 8 mesiacov pred
rodič
commit
c21d344993
1 zmenil súbory, kde vykonal 13 pridanie a 0 odobranie
  1. 13 0
      Projects/Src/Setup.SetupForm.pas

+ 13 - 0
Projects/Src/Setup.SetupForm.pas

@@ -47,6 +47,7 @@ type
     function ScalePixelsY(const N: Integer): Integer;
     function ShouldSizeX: Boolean;
     function ShouldSizeY: Boolean;
+    function ShowModal: Integer; override;
     procedure FlipSizeAndCenterIfNeeded(const ACenterInsideControl: Boolean = False;
       const CenterInsideControlCtl: TWinControl = nil;
       const CenterInsideControlInsideClientArea: Boolean = False); virtual;
@@ -489,6 +490,18 @@ begin
   Result := MulDiv(N, BaseUnitY, OrigBaseUnitY);
 end;
 
+function TSetupForm.ShowModal: Integer;
+begin
+  { Work around VCL issue (Delphi 11.3): ShowModal calls DisableTaskWindows
+    without ensuring the form's handle has been created first. If the handle
+    is created after DisableTaskWindows, PopupMode=pmAuto breaks;
+    TCustomForm.CreateParams finds that the active window is disabled, and
+    doesn't use it as the owner. It then falls back to pmNone behavior, which
+    is to use the main form or application window as the owner. }
+  HandleNeeded;
+  Result := inherited;
+end;
+
 procedure TSetupForm.VisibleChanging;
 begin
   inherited;