changeset 1964:cdd0561de878

Win: Initial code to handle the new dark mode in Windows 10 build 1809.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 27 Jul 2019 20:50:48 +0000
parents 80f6be39b7fe
children 6315f668f5f6
files win/dw.c
diffstat 1 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Fri Jul 26 23:20:54 2019 +0000
+++ b/win/dw.c	Sat Jul 27 20:50:48 2019 +0000
@@ -2,7 +2,7 @@
  * Dynamic Windows:
  *          A GTK like implementation of the Win32 GUI
  *
- * (C) 2000-2017 Brian Smith <brian@dbsoft.org>
+ * (C) 2000-2019 Brian Smith <brian@dbsoft.org>
  * (C) 2003-2011 Mark Hessling <mark@rexx.org>
  *
  */
@@ -671,6 +671,29 @@
 }
 #endif
 
+int _DW_DARK_MODE_ALLOWED = TRUE;
+
+/* Call this on a window to apply the style */
+void _set_window_theme(HWND window)
+{
+	static int initialized = FALSE;
+	BOOL (WINAPI * AllowDarkModeForWindow)(HWND a_HWND, BOOL a_Allow) = NULL;
+	
+	if(initialized == FALSE && dwVersion)
+	{
+		/* Dark mode is introduced in Windows 10 build 1809 */
+		if(LOBYTE(LOWORD(dwVersion)) == 10 && HIWORD(dwVersion) >= 1809)
+			AllowDarkModeForWindow = (BOOL (WINAPI *)(HWND, BOOL))GetProcAddress(huxtheme, MAKEINTRESOURCEA(133));
+		initialized = TRUE;
+	}
+	if(AllowDarkModeForWindow)
+	{
+		AllowDarkModeForWindow(window, _DW_DARK_MODE_ALLOWED);
+		if(_DW_DARK_MODE_ALLOWED && _SetWindowTheme)
+			_SetWindowTheme(window, L"Explorer", NULL);
+	}
+}
+
 /* This function adds a signal handler callback into the linked list.
  */
 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *discfunc, void *data)