Mercurial > dwindows
comparison win/dw.c @ 1966:d510e9bb61c2
Win: First attempt at enabling Dark Mode support, mixed results... some changes.
However just produces an awkward mess of light and dark mode widgets.
Setting support to FALSE by default.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 30 Jul 2019 07:53:57 +0000 |
parents | cdd0561de878 |
children | 2322769acf88 |
comparison
equal
deleted
inserted
replaced
1965:6315f668f5f6 | 1966:d510e9bb61c2 |
---|---|
669 } | 669 } |
670 return NULL; | 670 return NULL; |
671 } | 671 } |
672 #endif | 672 #endif |
673 | 673 |
674 int _DW_DARK_MODE_ALLOWED = TRUE; | 674 int _DW_DARK_MODE_ALLOWED = FALSE; |
675 | 675 |
676 /* Call this on a window to apply the style */ | 676 /* Call this on a window to apply the style */ |
677 void _set_window_theme(HWND window) | 677 BOOL CALLBACK _set_child_window_theme(HWND window, LPARAM lParam) |
678 { | 678 { |
679 static int initialized = FALSE; | 679 static int initialized = FALSE; |
680 BOOL (WINAPI * AllowDarkModeForWindow)(HWND a_HWND, BOOL a_Allow) = NULL; | 680 static BOOL (WINAPI * AllowDarkModeForWindow)(HWND a_HWND, BOOL a_Allow) = NULL; |
681 | 681 |
682 if(initialized == FALSE && dwVersion) | 682 if(initialized == FALSE && dwVersion) |
683 { | 683 { |
684 /* Dark mode is introduced in Windows 10 build 1809 */ | 684 /* Dark mode is introduced in Windows 10 (1809) build 17763 */ |
685 if(LOBYTE(LOWORD(dwVersion)) == 10 && HIWORD(dwVersion) >= 1809) | 685 if(LOBYTE(LOWORD(dwVersion)) >= 10 && HIWORD(dwVersion) >= 17763) |
686 AllowDarkModeForWindow = (BOOL (WINAPI *)(HWND, BOOL))GetProcAddress(huxtheme, MAKEINTRESOURCEA(133)); | 686 AllowDarkModeForWindow = (BOOL (WINAPI *)(HWND, BOOL))GetProcAddress(huxtheme, MAKEINTRESOURCEA(133)); |
687 initialized = TRUE; | 687 initialized = TRUE; |
688 } | 688 } |
689 if(AllowDarkModeForWindow) | 689 if(AllowDarkModeForWindow) |
690 { | 690 { |
691 AllowDarkModeForWindow(window, _DW_DARK_MODE_ALLOWED); | 691 AllowDarkModeForWindow(window, _DW_DARK_MODE_ALLOWED); |
692 if(_DW_DARK_MODE_ALLOWED && _SetWindowTheme) | 692 if(_DW_DARK_MODE_ALLOWED && _SetWindowTheme) |
693 _SetWindowTheme(window, L"Explorer", NULL); | 693 { |
694 } | 694 _SetWindowTheme(window, L"DarkMode_Explorer", NULL); |
695 } | |
696 } | |
697 return TRUE; | |
695 } | 698 } |
696 | 699 |
697 /* This function adds a signal handler callback into the linked list. | 700 /* This function adds a signal handler callback into the linked list. |
698 */ | 701 */ |
699 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *discfunc, void *data) | 702 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *discfunc, void *data) |
4267 int API dw_window_show(HWND handle) | 4270 int API dw_window_show(HWND handle) |
4268 { | 4271 { |
4269 int rc; | 4272 int rc; |
4270 RECT rect; | 4273 RECT rect; |
4271 | 4274 |
4275 /* Try to enable dark mode support if our OS supports it */ | |
4276 _set_child_window_theme(handle, 0); | |
4277 EnumChildWindows(handle, _set_child_window_theme, 0); | |
4278 | |
4272 GetClientRect(handle, &rect); | 4279 GetClientRect(handle, &rect); |
4273 | 4280 |
4274 /* If the client area is 0x0 then call the autosize routine */ | 4281 /* If the client area is 0x0 then call the autosize routine */ |
4275 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0) | 4282 if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0) |
4276 dw_window_set_size(handle, 0, 0); | 4283 dw_window_set_size(handle, 0, 0); |