浏览代码

Bug 1920: Use dark window title for the main window in the dark mode on Windows 10 2004 (2nd)

Previously the title was fixed to dark.

https://winscp.net/tracker/1920
(cherry picked from commit 6cf2f5d3c88fdabe78932fd55f4d97838a715fd1)

# Conflicts:
#	source/forms/CustomScpExplorer.h

Source commit: b18435386844422a249ecce0742f06f0292f6c5f
Martin Prikryl 5 年之前
父节点
当前提交
a6af5917d4
共有 2 个文件被更改,包括 17 次插入6 次删除
  1. 15 6
      source/forms/CustomScpExplorer.cpp
  2. 2 0
      source/forms/CustomScpExplorer.h

+ 15 - 6
source/forms/CustomScpExplorer.cpp

@@ -8695,6 +8695,10 @@ void __fastcall TCustomScpExplorerForm::UpdateControls()
 
     RemoteDirView->DarkMode = WinConfiguration->UseDarkTheme();
     RemoteDriveView->DarkMode = RemoteDirView->DarkMode;
+    if (FImmersiveDarkMode != WinConfiguration->UseDarkTheme())
+    {
+      UpdateDarkMode();
+    }
 
     reinterpret_cast<TTBCustomItem *>(GetComponent(fcRemotePathComboBox))->Enabled = HasTerminal;
   }
@@ -9690,18 +9694,23 @@ TDragDropFilesEx * __fastcall TCustomScpExplorerForm::CreateDragDropFilesEx()
   return Result;
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::CreateWnd()
+void __fastcall TCustomScpExplorerForm::UpdateDarkMode()
 {
-  TForm::CreateWnd();
-
-  // win32-darkmode calls AllowDarkModeForWindow(this, true) here, but it does not seem to have any effect
-
   if (IsWin10Build(2004))
   {
-    BOOL DarkMode = TRUE;
+    FImmersiveDarkMode = WinConfiguration->UseDarkTheme();
+    BOOL DarkMode = FImmersiveDarkMode ? TRUE : FALSE;
     const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
     DwmSetWindowAttribute(Handle, DWMWA_USE_IMMERSIVE_DARK_MODE, &DarkMode, sizeof(DarkMode));
   }
+}
+//---------------------------------------------------------------------------
+void __fastcall TCustomScpExplorerForm::CreateWnd()
+{
+  TForm::CreateWnd();
+
+  // win32-darkmode calls AllowDarkModeForWindow(this, true) here, but it does not seem to have any effect
+  UpdateDarkMode();
 
   if (FSessionsDragDropFilesEx == NULL)
   {

+ 2 - 0
source/forms/CustomScpExplorer.h

@@ -380,6 +380,7 @@ protected:
   UnicodeString FIncrementalSearch;
   int FIncrementalSearching;
   bool FIncrementalSearchHaveNext;
+  bool FImmersiveDarkMode;
 
   virtual bool __fastcall CopyParamDialog(TTransferDirection Direction,
     TTransferType Type, bool Temp, TStrings * FileList,
@@ -711,6 +712,7 @@ protected:
   int __fastcall GetMinQueueViewHeight();
   void __fastcall DetachTerminal(TObject * ATerminal);
   bool __fastcall IsActiveTerminal(TTerminal * Terminal);
+  void __fastcall UpdateDarkMode();
 
 public:
   virtual __fastcall ~TCustomScpExplorerForm();