# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1564260648 0 # Node ID cdd0561de878bfc70e809cbbf8f4b81bae704662 # Parent 80f6be39b7fe670a64a58c5b95983fa307212e5e Win: Initial code to handle the new dark mode in Windows 10 build 1809. diff -r 80f6be39b7fe -r cdd0561de878 win/dw.c --- 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 + * (C) 2000-2019 Brian Smith * (C) 2003-2011 Mark Hessling * */ @@ -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)