changeset 1971:d39f4f9bed26

Win: Change to allow dark mode for the folder browser window.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 05 Aug 2019 15:38:21 +0000
parents 8cf330e1e331
children 8e650172d8cf
files win/XBrowseForFolder.cpp
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/win/XBrowseForFolder.cpp	Fri Aug 02 13:32:38 2019 +0000
+++ b/win/XBrowseForFolder.cpp	Mon Aug 05 15:38:21 2019 +0000
@@ -211,6 +211,20 @@
 	}
 }
 
+#ifdef AEROGLASS
+extern "C" {
+/* Include necessary variables and prototypes from dw.c */
+extern int _DW_DARK_MODE_SUPPORTED;
+extern int _DW_DARK_MODE_ENABLED;
+extern BOOL (WINAPI * _ShouldAppsUseDarkMode)(VOID);
+
+BOOL IsHighContrast(VOID);
+BOOL IsColorSchemeChangeMessage(LPARAM lParam);
+void RefreshTitleBarThemeColor(HWND window);
+BOOL CALLBACK _dw_set_child_window_theme(HWND window, LPARAM lParam);
+}
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 // BrowseCallbackProc - SHBrowseForFolder callback function
 static int CALLBACK BrowseCallbackProc(HWND hWnd,		// Window handle to the browse dialog box
@@ -222,6 +236,20 @@
 {
 	switch (uMsg)
 	{
+#ifdef AEROGLASS
+		case WM_SETTINGCHANGE:
+		{
+			if(_DW_DARK_MODE_SUPPORTED && IsColorSchemeChangeMessage(lpData))
+			{
+				_DW_DARK_MODE_ENABLED = _ShouldAppsUseDarkMode() && !IsHighContrast();
+
+				RefreshTitleBarThemeColor(hWnd);
+				_dw_set_child_window_theme(hWnd, 0);
+				EnumChildWindows(hWnd, _dw_set_child_window_theme, 0);
+			}
+		}
+		break;
+#endif
 		case BFFM_INITIALIZED:		// sent when the browse dialog box has finished initializing.
 		{
 			// remove context help button from dialog caption
@@ -248,6 +276,14 @@
 				}
 			}
 
+#ifdef AEROGLASS
+			if(_DW_DARK_MODE_SUPPORTED)
+			{
+				_dw_set_child_window_theme(hWnd, 0);
+				EnumChildWindows(hWnd, _dw_set_child_window_theme, 0);
+				RefreshTitleBarThemeColor(hWnd);
+			}
+#endif
 			SizeBrowseDialog(hWnd, fp);
 		}
 		break;