瀏覽代碼

Dark mode for internal editor + AllowDarkModeForWindow needs recreating window (though it still does not work reliably)

Source commit: 2ce2751091af2059f69aadb32a90e7eec5cb1e76
Martin Prikryl 7 年之前
父節點
當前提交
98e4fe1969

+ 6 - 25
source/forms/CustomScpExplorer.cpp

@@ -999,7 +999,7 @@ void __fastcall TCustomScpExplorerForm::UpdateSessionsPageControlHeight()
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::ConfigurationChanged()
 void __fastcall TCustomScpExplorerForm::ConfigurationChanged()
 {
 {
-  Color = WinConfiguration->UseDarkTheme() ? TColor(RGB(43, 43, 43)) : clBtnFace;
+  Color = GetBtnFaceColor();
 
 
   DebugAssert(Configuration && RemoteDirView);
   DebugAssert(Configuration && RemoteDirView);
   RemoteDirView->DimmHiddenFiles = WinConfiguration->DimmHiddenFiles;
   RemoteDirView->DimmHiddenFiles = WinConfiguration->DimmHiddenFiles;
@@ -8324,22 +8324,9 @@ UnicodeString __fastcall TCustomScpExplorerForm::PathForCaption()
   return Result;
   return Result;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-TColor __fastcall TCustomScpExplorerForm::DefaultPanelColor()
-{
-  TColor Result = (WinConfiguration->UseDarkTheme() ? static_cast<TColor>(RGB(0x20, 0x20, 0x20)) : clWindow);
-  return Result;
-}
-//---------------------------------------------------------------------------
 TColor __fastcall TCustomScpExplorerForm::PanelColor()
 TColor __fastcall TCustomScpExplorerForm::PanelColor()
 {
 {
-  TColor Result = (FSessionColor != 0 ? FSessionColor : DefaultPanelColor());
-  return Result;
-}
-//---------------------------------------------------------------------------
-TColor __fastcall TCustomScpExplorerForm::PanelFontColor(TColor BackgroundColor)
-{
-  TColor Result = (IsDarkColor(BackgroundColor) ? clWhite : clWindowText);
-  SetContrast(Result, BackgroundColor, 180);
+  TColor Result = GetWindowColor(FSessionColor);
   return Result;
   return Result;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
@@ -8390,24 +8377,18 @@ void __fastcall TCustomScpExplorerForm::UpdateControls()
       }
       }
     }
     }
 
 
-    RemoteDirView->Font->Color = PanelFontColor(RemoteDirView->Color);
+    RemoteDirView->Font->Color = GetWindowTextColor(RemoteDirView->Color);
 
 
     RemoteDriveView->Enabled = RemoteDirView->Enabled;
     RemoteDriveView->Enabled = RemoteDirView->Enabled;
     RemoteDriveView->Color = RemoteDirView->Color;
     RemoteDriveView->Color = RemoteDirView->Color;
     RemoteDriveView->Font->Color = RemoteDirView->Font->Color;
     RemoteDriveView->Font->Color = RemoteDirView->Font->Color;
 
 
     QueueView3->Enabled = HasTerminal && Terminal->IsCapable[fsBackgroundTransfers];
     QueueView3->Enabled = HasTerminal && Terminal->IsCapable[fsBackgroundTransfers];
-    QueueView3->Color = QueueView3->Enabled ? DefaultPanelColor() : DisabledPanelColor();
+    QueueView3->Color = QueueView3->Enabled ? GetWindowColor() : DisabledPanelColor();
     QueueLabelUpdateStatus();
     QueueLabelUpdateStatus();
 
 
-    bool UseDarkTheme = WinConfiguration->UseDarkTheme();
-    AllowDarkModeForWindow(RemoteDirView, UseDarkTheme);
-    AllowDarkModeForWindow(RemoteDriveView, UseDarkTheme);
-    AllowDarkModeForWindow(SessionsPageControl, UseDarkTheme);
-    if (QueueView3->HandleAllocated())
-    {
-      AllowDarkModeForWindow(QueueView3, UseDarkTheme);
-    }
+    RemoteDirView->DarkMode = WinConfiguration->UseDarkTheme();
+    RemoteDriveView->DarkMode = RemoteDirView->DarkMode;
 
 
     reinterpret_cast<TTBCustomItem *>(GetComponent(fcRemotePathComboBox))->Enabled = HasTerminal;
     reinterpret_cast<TTBCustomItem *>(GetComponent(fcRemotePathComboBox))->Enabled = HasTerminal;
   }
   }

+ 0 - 2
source/forms/CustomScpExplorer.h

@@ -651,9 +651,7 @@ protected:
   void __fastcall CloseSessionTab(int Index);
   void __fastcall CloseSessionTab(int Index);
   void __fastcall DoFileColorsChanged(TCustomDirView * DirView);
   void __fastcall DoFileColorsChanged(TCustomDirView * DirView);
   virtual void __fastcall FileColorsChanged();
   virtual void __fastcall FileColorsChanged();
-  TColor __fastcall DefaultPanelColor();
   TColor __fastcall PanelColor();
   TColor __fastcall PanelColor();
-  TColor __fastcall PanelFontColor(TColor BackgroundColor);
   TColor __fastcall DisabledPanelColor();
   TColor __fastcall DisabledPanelColor();
   void __fastcall WMWinIniChange(TMessage & Message);
   void __fastcall WMWinIniChange(TMessage & Message);
 
 

+ 3 - 1
source/forms/Editor.cpp

@@ -201,7 +201,7 @@ void __fastcall TEditorRichEdit::ApplyFont()
   std::unique_ptr<TFont> NewFont(new TFont());
   std::unique_ptr<TFont> NewFont(new TFont());
   TWinConfiguration::RestoreFont(FFontConfiguration, NewFont.get());
   TWinConfiguration::RestoreFont(FFontConfiguration, NewFont.get());
   NewFont->Size = ScaleByPixelsPerInchFromSystem(NewFont->Size, this);
   NewFont->Size = ScaleByPixelsPerInchFromSystem(NewFont->Size, this);
-  NewFont->Color = GetWindowTextColor(FFontColor);
+  NewFont->Color = GetWindowTextColor(Color, FFontColor);
   // setting DefAttributes may take quite time, even if the font attributes
   // setting DefAttributes may take quite time, even if the font attributes
   // do not change, so avoid that if not necessary
   // do not change, so avoid that if not necessary
   if (!FInitialized ||
   if (!FInitialized ||
@@ -986,6 +986,7 @@ void __fastcall TEditorForm::FormCloseQuery(TObject * /*Sender*/,
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 void __fastcall TEditorForm::ApplyConfiguration()
 void __fastcall TEditorForm::ApplyConfiguration()
 {
 {
+  Color = GetBtnFaceColor();
   bool PrevModified = IsFileModified();
   bool PrevModified = IsFileModified();
   DebugAssert(Configuration);
   DebugAssert(Configuration);
   EditorMemo->SetFormat(WinConfiguration->Editor.Font,
   EditorMemo->SetFormat(WinConfiguration->Editor.Font,
@@ -1622,6 +1623,7 @@ void __fastcall TEditorForm::UpdateBackgroundColor()
   if (EditorMemo->Color != Color)
   if (EditorMemo->Color != Color)
   {
   {
     EditorMemo->Color = Color;
     EditorMemo->Color = Color;
+    EditorMemo->ApplyFont();
     // does not seem to have any effect (nor is needed), but just in case
     // does not seem to have any effect (nor is needed), but just in case
     ForceColorChange(EditorMemo);
     ForceColorChange(EditorMemo);
   }
   }

+ 2 - 2
source/forms/Preferences.cpp

@@ -1178,16 +1178,16 @@ void __fastcall TPreferencesDialog::UpdateControls()
     EditorFontLabelText += TabSample(L"ABCD") + L"\n";
     EditorFontLabelText += TabSample(L"ABCD") + L"\n";
     EditorFontLabelText += TabSample(L"1234");
     EditorFontLabelText += TabSample(L"1234");
     EditorFontLabel->Caption = EditorFontLabelText;
     EditorFontLabel->Caption = EditorFontLabelText;
+    EditorFontLabel->Color = GetWindowColor(FEditorBackgroundColor);
     std::unique_ptr<TFont> EditorFont(new TFont());
     std::unique_ptr<TFont> EditorFont(new TFont());
     EditorFont->Assign(FEditorFont.get());
     EditorFont->Assign(FEditorFont.get());
-    EditorFont->Color = GetWindowTextColor(FEditorFont->Color);
+    EditorFont->Color = GetWindowTextColor(EditorFontLabel->Color, FEditorFont->Color);
     EditorFont->Size = ScaleByPixelsPerInchFromSystem(FEditorFont->Size, this);
     EditorFont->Size = ScaleByPixelsPerInchFromSystem(FEditorFont->Size, this);
     if (!SameFont(EditorFontLabel->Font, EditorFont.get()) ||
     if (!SameFont(EditorFontLabel->Font, EditorFont.get()) ||
         (EditorFontLabel->Font->Color != EditorFont->Color))
         (EditorFontLabel->Font->Color != EditorFont->Color))
     {
     {
       EditorFontLabel->Font = EditorFont.get();
       EditorFontLabel->Font = EditorFont.get();
     }
     }
-    EditorFontLabel->Color = GetWindowColor(FEditorBackgroundColor);
 
 
     TCustomCommandList * CommandList = GetCommandList(CustomCommandsView->ItemIndex);
     TCustomCommandList * CommandList = GetCommandList(CustomCommandsView->ItemIndex);
     int CommandIndex = GetCommandIndex(CustomCommandsView->ItemIndex);
     int CommandIndex = GetCommandIndex(CustomCommandsView->ItemIndex);

+ 3 - 9
source/forms/ScpCommander.cpp

@@ -806,17 +806,11 @@ void __fastcall TScpCommanderForm::UpdateControls()
     // command line combo width needs to be updated as caption width has probably changed
     // command line combo width needs to be updated as caption width has probably changed
     ToolBarResize(CommandLineToolbar);
     ToolBarResize(CommandLineToolbar);
   }
   }
-  if (LocalDirView->HandleAllocated())
-  {
-    AllowDarkModeForWindow(LocalDirView, WinConfiguration->UseDarkTheme());
-  }
-  if (LocalDriveView->HandleAllocated())
-  {
-    AllowDarkModeForWindow(LocalDriveView, WinConfiguration->UseDarkTheme());
-  }
+  LocalDirView->DarkMode = WinConfiguration->UseDarkTheme();
+  LocalDriveView->DarkMode = LocalDirView->DarkMode;
   LocalDirView->Color = PanelColor();
   LocalDirView->Color = PanelColor();
   LocalDriveView->Color = LocalDirView->Color;
   LocalDriveView->Color = LocalDirView->Color;
-  LocalDirView->Font->Color = PanelFontColor(LocalDirView->Color);
+  LocalDirView->Font->Color = GetWindowTextColor(LocalDirView->Color);
   LocalDriveView->Font->Color = LocalDirView->Font->Color;
   LocalDriveView->Font->Color = LocalDirView->Font->Color;
 
 
   bool LocalSide = (FCurrentSide == osLocal);
   bool LocalSide = (FCurrentSide == osLocal);

+ 15 - 0
source/packages/filemng/CustomDirView.pas

@@ -165,6 +165,7 @@ type
     FOnGetItemColor: TDirViewGetItemColorEvent;
     FOnGetItemColor: TDirViewGetItemColorEvent;
     FMask: string;
     FMask: string;
     FNaturalOrderNumericalSorting: Boolean;
     FNaturalOrderNumericalSorting: Boolean;
+    FDarkMode: Boolean;
     FScrollOnDragOver: TListViewScrollOnDragOver;
     FScrollOnDragOver: TListViewScrollOnDragOver;
     FStatusFileInfo: TStatusFileInfo;
     FStatusFileInfo: TStatusFileInfo;
     FDoubleBufferedScrollingWorkaround: Boolean;
     FDoubleBufferedScrollingWorkaround: Boolean;
@@ -309,6 +310,7 @@ type
     function EnableDragOnClick: Boolean; override;
     function EnableDragOnClick: Boolean; override;
     procedure SetMask(Value: string); virtual;
     procedure SetMask(Value: string); virtual;
     procedure SetNaturalOrderNumericalSorting(Value: Boolean);
     procedure SetNaturalOrderNumericalSorting(Value: Boolean);
+    procedure SetDarkMode(Value: Boolean);
     procedure ScrollOnDragOverBeforeUpdate(ObjectToValidate: TObject);
     procedure ScrollOnDragOverBeforeUpdate(ObjectToValidate: TObject);
     procedure ScrollOnDragOverAfterUpdate;
     procedure ScrollOnDragOverAfterUpdate;
     procedure DoHistoryGo(Index: Integer);
     procedure DoHistoryGo(Index: Integer);
@@ -417,6 +419,7 @@ type
     {filemask, multiple filters are possible: '*.pas;*.dfm'}
     {filemask, multiple filters are possible: '*.pas;*.dfm'}
     property Mask: string read FMask write SetMask;
     property Mask: string read FMask write SetMask;
     property NaturalOrderNumericalSorting: Boolean read FNaturalOrderNumericalSorting write SetNaturalOrderNumericalSorting;
     property NaturalOrderNumericalSorting: Boolean read FNaturalOrderNumericalSorting write SetNaturalOrderNumericalSorting;
+    property DarkMode: Boolean read FDarkMode write SetDarkMode;
 
 
     property OnContextPopup;
     property OnContextPopup;
     property OnStartLoading: TNotifyEvent read FOnStartLoading write FOnStartLoading;
     property OnStartLoading: TNotifyEvent read FOnStartLoading write FOnStartLoading;
@@ -822,6 +825,7 @@ begin
   FExeDrag := False;
   FExeDrag := False;
   FMask := '';
   FMask := '';
   FNaturalOrderNumericalSorting := True;
   FNaturalOrderNumericalSorting := True;
+  FDarkMode := False;
   FDoubleBufferedScrollingWorkaround := not IsVistaHard();
   FDoubleBufferedScrollingWorkaround := not IsVistaHard();
 
 
   FOnHistoryChange := nil;
   FOnHistoryChange := nil;
@@ -1154,6 +1158,8 @@ begin
     PopupMenu.Autopopup := False;
     PopupMenu.Autopopup := False;
   FDragDropFilesEx.DragDropControl := Self;
   FDragDropFilesEx.DragDropControl := Self;
 
 
+  if DarkMode then AllowDarkModeForWindow(Self, DarkMode);
+
   NeedImageLists(False);
   NeedImageLists(False);
 end;
 end;
 
 
@@ -3171,6 +3177,15 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TCustomDirView.SetDarkMode(Value: Boolean);
+begin
+  if DarkMode <> Value then
+  begin
+    FDarkMode := Value;
+    RecreateWnd;
+  end;
+end;
+
 // WM_SETFOCUS works even when focus is moved to another window/app,
 // WM_SETFOCUS works even when focus is moved to another window/app,
 // while .Enter works only when focus is moved to other control of the same window.
 // while .Enter works only when focus is moved to other control of the same window.
 procedure TCustomDirView.WMSetFocus(var Message: TWMSetFocus);
 procedure TCustomDirView.WMSetFocus(var Message: TWMSetFocus);

+ 15 - 0
source/packages/filemng/CustomDriveView.pas

@@ -39,6 +39,7 @@ type
     FDimmHiddenDirs: Boolean;
     FDimmHiddenDirs: Boolean;
     FShowHiddenDirs: Boolean;
     FShowHiddenDirs: Boolean;
     FNaturalOrderNumericalSorting: Boolean;
     FNaturalOrderNumericalSorting: Boolean;
+    FDarkMode: Boolean;
     FContinue: Boolean;
     FContinue: Boolean;
     FImageList: TImageList;
     FImageList: TImageList;
     FScrollOnDragOver: TTreeViewScrollOnDragOver;
     FScrollOnDragOver: TTreeViewScrollOnDragOver;
@@ -67,6 +68,7 @@ type
     procedure SetDimmHiddenDirs(Value: Boolean);
     procedure SetDimmHiddenDirs(Value: Boolean);
     procedure SetShowHiddenDirs(Value: Boolean);
     procedure SetShowHiddenDirs(Value: Boolean);
     procedure SetNaturalOrderNumericalSorting(Value: Boolean);
     procedure SetNaturalOrderNumericalSorting(Value: Boolean);
+    procedure SetDarkMode(Value: Boolean);
 
 
     function GetDirectory: string; virtual;
     function GetDirectory: string; virtual;
     procedure SetDirectory(Value: string); virtual;
     procedure SetDirectory(Value: string); virtual;
@@ -174,6 +176,7 @@ type
     property ShowHiddenDirs: Boolean read FShowHiddenDirs
     property ShowHiddenDirs: Boolean read FShowHiddenDirs
       write SetShowHiddenDirs default False;
       write SetShowHiddenDirs default False;
     property NaturalOrderNumericalSorting: Boolean read FNaturalOrderNumericalSorting write SetNaturalOrderNumericalSorting;
     property NaturalOrderNumericalSorting: Boolean read FNaturalOrderNumericalSorting write SetNaturalOrderNumericalSorting;
+    property DarkMode: Boolean read FDarkMode write SetDarkMode;
 
 
     property DDLinkOnExeDrag: Boolean read FDDLinkOnExeDrag write FDDLinkOnExeDrag default True;
     property DDLinkOnExeDrag: Boolean read FDDLinkOnExeDrag write FDDLinkOnExeDrag default True;
 
 
@@ -245,6 +248,7 @@ begin
   FUseSystemContextMenu := True;
   FUseSystemContextMenu := True;
   FContinue := True;
   FContinue := True;
   FNaturalOrderNumericalSorting := True;
   FNaturalOrderNumericalSorting := True;
+  FDarkMode := False;
   OnCompare := DoCompare;
   OnCompare := DoCompare;
 
 
   FDragDropFilesEx := TCustomizableDragDropFilesEx.Create(Self);
   FDragDropFilesEx := TCustomizableDragDropFilesEx.Create(Self);
@@ -342,6 +346,8 @@ procedure TCustomDriveView.CreateWnd;
 begin
 begin
   inherited;
   inherited;
 
 
+  if DarkMode then AllowDarkModeForWindow(Self, DarkMode);
+
   NeedImageLists(False);
   NeedImageLists(False);
 
 
   if not (csDesigning in ComponentState) then
   if not (csDesigning in ComponentState) then
@@ -1203,6 +1209,15 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TCustomDriveView.SetDarkMode(Value: Boolean);
+begin
+  if DarkMode <> Value then
+  begin
+    FDarkMode := Value;
+    RecreateWnd;
+  end;
+end;
+
 function TCustomDriveView.GetTargetPopupMenu: Boolean;
 function TCustomDriveView.GetTargetPopupMenu: Boolean;
 begin
 begin
   if Assigned(FDragDropFilesEx) then Result := FDragDropFilesEx.TargetPopupMenu
   if Assigned(FDragDropFilesEx) then Result := FDragDropFilesEx.TargetPopupMenu

+ 32 - 0
source/packages/my/PasTools.pas

@@ -79,6 +79,8 @@ procedure ForceColorChange(Control: TWinControl);
 
 
 function IsUncPath(Path: string): Boolean;
 function IsUncPath(Path: string): Boolean;
 
 
+procedure AllowDarkModeForWindow(Control: TWinControl; Allow: Boolean);
+
 type
 type
   TApiPathEvent = function(Path: string): string;
   TApiPathEvent = function(Path: string): string;
 
 
@@ -974,6 +976,36 @@ begin
   Result := (Copy(Path, 1, 2) = '\\') or (Copy(Path, 1, 2) = '//');
   Result := (Copy(Path, 1, 2) = '\\') or (Copy(Path, 1, 2) = '//');
 end;
 end;
 
 
+var
+  AllowDarkModeForWindowLoaded: Boolean = False;
+  AAllowDarkModeForWindow: function(hWnd: HWND; Allow: BOOL): BOOL; stdcall;
+
+procedure AllowDarkModeForWindow(Control: TWinControl; Allow: Boolean);
+var
+  OSVersionInfo: TOSVersionInfoEx;
+  UxThemeLib: HMODULE;
+begin
+  if not AllowDarkModeForWindowLoaded then
+  begin
+    OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo);
+    if GetVersionEx(OSVersionInfo) and (OSVersionInfo.dwBuildNumber >= 17763) then
+    begin
+      UxThemeLib := GetModuleHandle('UxTheme');
+      if UxThemeLib <> 0 then
+      begin
+        AAllowDarkModeForWindow := GetProcAddress(UxThemeLib, MakeIntResource(133));
+      end;
+    end;
+    AllowDarkModeForWindowLoaded := True;
+  end;
+
+  Assert(Control.HandleAllocated);
+  if Assigned(AAllowDarkModeForWindow) and Control.HandleAllocated then
+  begin
+    AAllowDarkModeForWindow(Control.Handle, Allow);
+  end;
+end;
+
 var
 var
   Lib: THandle;
   Lib: THandle;
 initialization
 initialization

+ 17 - 3
source/windows/Tools.cpp

@@ -106,14 +106,28 @@ bool __fastcall SameFont(TFont * Font1, TFont * Font2)
     (Font1->Charset == Font2->Charset) && (Font1->Style == Font2->Style);
     (Font1->Charset == Font2->Charset) && (Font1->Style == Font2->Style);
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-TColor __fastcall GetWindowTextColor(TColor Color)
+TColor __fastcall GetWindowTextColor(TColor BackgroundColor, TColor Color)
 {
 {
-  return (Color == TColor(0)) ? clWindowText : Color;
+  if (Color == TColor(0))
+  {
+    Color = (IsDarkColor(BackgroundColor) ? clWhite : clWindowText);
+    SetContrast(Color, BackgroundColor, 180);
+  }
+  return Color;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 TColor __fastcall GetWindowColor(TColor Color)
 TColor __fastcall GetWindowColor(TColor Color)
 {
 {
-  return (Color == TColor(0)) ? clWindow : Color;
+  if (Color == TColor(0))
+  {
+    Color = (WinConfiguration->UseDarkTheme() ? static_cast<TColor>(RGB(0x20, 0x20, 0x20)) : clWindow);
+  }
+  return Color;
+}
+//---------------------------------------------------------------------------
+TColor __fastcall GetBtnFaceColor()
+{
+  return WinConfiguration->UseDarkTheme() ? TColor(RGB(43, 43, 43)) : clBtnFace;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 TColor __fastcall GetNonZeroColor(TColor Color)
 TColor __fastcall GetNonZeroColor(TColor Color)

+ 3 - 2
source/windows/Tools.h

@@ -34,8 +34,9 @@ UnicodeString __fastcall StoreFormSize(TForm * Form);
 TFontStyles __fastcall IntToFontStyles(int value);
 TFontStyles __fastcall IntToFontStyles(int value);
 int __fastcall FontStylesToInt(const TFontStyles value);
 int __fastcall FontStylesToInt(const TFontStyles value);
 bool __fastcall SameFont(TFont * Font1, TFont * Font2);
 bool __fastcall SameFont(TFont * Font1, TFont * Font2);
-TColor __fastcall GetWindowTextColor(TColor Color);
-TColor __fastcall GetWindowColor(TColor Color);
+TColor __fastcall GetWindowTextColor(TColor BackgroundColor, TColor Color = static_cast<TColor>(0));
+TColor __fastcall GetWindowColor(TColor Color = static_cast<TColor>(0));
+TColor __fastcall GetBtnFaceColor();
 TColor __fastcall GetNonZeroColor(TColor Color);
 TColor __fastcall GetNonZeroColor(TColor Color);
 void __fastcall ValidateMaskEdit(TComboBox * Edit);
 void __fastcall ValidateMaskEdit(TComboBox * Edit);
 void __fastcall ValidateMaskEdit(TEdit * Edit);
 void __fastcall ValidateMaskEdit(TEdit * Edit);

+ 0 - 30
source/windows/VCLCommon.cpp

@@ -2721,33 +2721,3 @@ TPanel * __fastcall CreateBlankPanel(TComponent * Owner)
   Panel->BevelKind = bkNone;
   Panel->BevelKind = bkNone;
   return Panel;
   return Panel;
 }
 }
-//---------------------------------------------------------------------------
-typedef bool (WINAPI * AllowDarkModeForWindowProc)(HWND Handle, bool Allow);
-AllowDarkModeForWindowProc AAllowDarkModeForWindow = NULL;
-bool AllowDarkModeForWindowLoaded = false;
-bool AllowDarkModeCalledWithTrue = false;
-void AllowDarkModeForWindow(TWinControl * Control, bool Allow)
-{
-  if (Allow)
-  {
-    // Do not try to call AllowDarkModeForWindow with false, unless we ever called it with true, so that,
-    // if function changes it ID, we can prevent its call by turning off dark mode.
-    AllowDarkModeCalledWithTrue = true;
-  }
-  if (AllowDarkModeCalledWithTrue && (GetWindowsBuild() >= 17763) && !AllowDarkModeForWindowLoaded)
-  {
-    HMODULE UxThemeLib = GetModuleHandle(L"UxTheme");
-    if (DebugAlwaysTrue(UxThemeLib != NULL))
-    {
-      AAllowDarkModeForWindow =
-        reinterpret_cast<AllowDarkModeForWindowProc>(GetProcAddress(UxThemeLib, MAKEINTRESOURCEA(133)));
-    }
-    AllowDarkModeForWindowLoaded = true;
-  }
-
-  if ((AAllowDarkModeForWindow != NULL) &&
-      DebugAlwaysTrue(Control->HandleAllocated()))
-  {
-    AAllowDarkModeForWindow(Control->Handle, Allow);
-  }
-}

+ 0 - 1
source/windows/VCLCommon.h

@@ -80,7 +80,6 @@ void __fastcall HookFormActivation(TCustomForm * Form);
 void __fastcall UnhookFormActivation(TCustomForm * Form);
 void __fastcall UnhookFormActivation(TCustomForm * Form);
 void __fastcall ShowFormNoActivate(TForm * Form);
 void __fastcall ShowFormNoActivate(TForm * Form);
 TPanel * __fastcall CreateBlankPanel(TComponent * Owner);
 TPanel * __fastcall CreateBlankPanel(TComponent * Owner);
-void AllowDarkModeForWindow(TWinControl * Control, bool Allow);
 typedef void __fastcall (*TRescaleEvent)(TComponent * Sender, TObject * Token);
 typedef void __fastcall (*TRescaleEvent)(TComponent * Sender, TObject * Token);
 void __fastcall SetRescaleFunction(
 void __fastcall SetRescaleFunction(
   TComponent * Component, TRescaleEvent OnRescale, TObject * Token = NULL, bool OwnsToken = false);
   TComponent * Component, TRescaleEvent OnRescale, TObject * Token = NULL, bool OwnsToken = false);