Przeglądaj źródła

Stop VCL Styles from breaking TaskDialog's title bar. (It makes the background dark but does not make the text light.)

Martijn Laan 1 miesiąc temu
rodzic
commit
a5d3a96c2b

+ 2 - 2
Components/BrowseFunc.pas

@@ -2,7 +2,7 @@ unit BrowseFunc;
 
 {
   Inno Setup
-  Copyright (C) 1997-2024 Jordan Russell
+  Copyright (C) 1997-2025 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -168,7 +168,7 @@ begin
   ActiveWindow := GetActiveWindow;
   WindowList := DisableTaskWindows(ParentWnd);
   { Temporarily clear SystemHooks to make it support dark mode if Windows is in dark mode.
-    Taken from Vcl.Dialogs' TCustomFileDialog.Execute }
+    Taken from Vcl.Dialogs' TCustomFileDialog.Execute. }
   const SaveHooks = TStyleManager.SystemHooks;
   TStyleManager.SystemHooks := [];
   try

+ 7 - 2
Projects/Src/Shared.TaskDialogFunc.pas

@@ -2,7 +2,7 @@ unit Shared.TaskDialogFunc;
 
 {
   Inno Setup
-  Copyright (C) 1997-2020 Jordan Russell
+  Copyright (C) 1997-2025 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -19,7 +19,7 @@ function TaskDialogMsgBox(const Icon, Instruction, Text, Caption: String; const
 implementation
 
 uses
-  Classes, StrUtils, Math, Forms, Dialogs, SysUtils,
+  Classes, StrUtils, Math, Forms, Dialogs, SysUtils, Themes,
   Commctrl, Shared.CommonFunc, {$IFDEF SETUPPROJ} Setup.InstFunc, {$ENDIF} PathFunc;
 
 var
@@ -81,9 +81,14 @@ begin
       TriggerMessageBoxCallbackFunc(TriggerMessageBoxCallbackFuncFlags, False);
       ActiveWindow := GetActiveWindow;
       WindowList := DisableTaskWindows(Config.hwndParent);
+      { Temporarily clear SystemHooks to stop it from breaking the title bar. Does not make it dark.
+        Also see BrowseFunc's NewGetOpenOrSaveFileName. }
+      const SaveHooks = TStyleManager.SystemHooks;
+      TStyleManager.SystemHooks := [];
       try
         Result := TaskDialogIndirectFunc(Config, @ModalResult, nil, pfVerificationFlagChecked) = S_OK;
       finally
+        TStyleManager.SystemHooks := SaveHooks;
         EnableTaskWindows(WindowList);
         SetActiveWindow(ActiveWindow);
         TriggerMessageBoxCallbackFunc(TriggerMessageBoxCallbackFuncFlags, True);