comparison win/dw.c @ 1980:38a455d2096c

Win: Disable window styles for checkboxes, radio buttons and groupboxes. With themes not disabled, they cannot change text color.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 13 Aug 2019 06:35:13 +0000
parents 290e661abb63
children ccd34ec31971
comparison
equal deleted inserted replaced
1979:290e661abb63 1980:38a455d2096c
747 _DW_DARK_MODE_ENABLED = _ShouldAppsUseDarkMode() && !IsHighContrast(); 747 _DW_DARK_MODE_ENABLED = _ShouldAppsUseDarkMode() && !IsHighContrast();
748 } 748 }
749 } 749 }
750 } 750 }
751 751
752 BOOL _CanThemeWindow(HWND window)
753 {
754 TCHAR tmpbuf[100] = {0};
755 LONG_PTR style = GetWindowLongPtr(window, GWL_STYLE);
756
757 GetClassName(window, tmpbuf, 99);
758
759 /* Some controls don't display properly with visual styles enabled */
760 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0 &&
761 (style & (BS_AUTOCHECKBOX | BS_CHECKBOX | BS_RADIOBUTTON)))
762 return FALSE;
763 #ifdef TOOLBAR
764 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
765 return FALSE;
766 #endif
767 return TRUE;
768 }
769
752 BOOL AllowDarkModeForWindow(HWND window, BOOL allow) 770 BOOL AllowDarkModeForWindow(HWND window, BOOL allow)
753 { 771 {
754 if(_DW_DARK_MODE_SUPPORTED) 772 if(_DW_DARK_MODE_SUPPORTED)
755 { 773 {
756 if(_DW_DARK_MODE_ALLOWED == 2) 774 if(_DW_DARK_MODE_ALLOWED == 2)
757 { 775 {
758 #ifdef TOOLBAR 776 if(_CanThemeWindow(window))
759 TCHAR tmpbuf[100] = {0};
760
761 GetClassName(window, tmpbuf, 99);
762
763 /* Toolbar controls don't display properly with visual styles enabled */
764 if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) != 0)
765 #endif
766 { 777 {
767 if(_DW_DARK_MODE_ENABLED) 778 if(_DW_DARK_MODE_ENABLED)
768 _SetWindowTheme(window, L"DarkMode_Explorer", NULL); 779 _SetWindowTheme(window, L"DarkMode_Explorer", NULL);
769 else 780 else
770 _SetWindowTheme(window, L"Explorer", NULL); 781 _SetWindowTheme(window, L"Explorer", NULL);
5620 hwndframe, 5631 hwndframe,
5621 NULL, 5632 NULL,
5622 DWInstance, 5633 DWInstance,
5623 NULL); 5634 NULL);
5624 5635
5636 /* Disable visual styles by default */
5637 if(_SetWindowTheme)
5638 _SetWindowTheme(newbox->grouphwnd, L"", L"");
5639
5625 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); 5640 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
5626 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc); 5641 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
5627 dw_window_set_font(hwndframe, DefaultFont); 5642 dw_window_set_font(hwndframe, DefaultFont);
5628 return hwndframe; 5643 return hwndframe;
5629 } 5644 }
6558 return 0; 6573 return 0;
6559 6574
6560 /* Create the toolbar */ 6575 /* Create the toolbar */
6561 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_AUTOSIZE | CCS_NORESIZE | 6576 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_AUTOSIZE | CCS_NORESIZE |
6562 CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)(uintptr_t)id, DWInstance, NULL); 6577 CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)(uintptr_t)id, DWInstance, NULL);
6563 6578
6564 /* Disable visual styles by default */ 6579 /* Disable visual styles by default */
6565 if(_SetWindowTheme) 6580 if(_SetWindowTheme)
6566 _SetWindowTheme(tmp, L"", L""); 6581 _SetWindowTheme(tmp, L"", L"");
6567 6582
6568 /* Insert the single bitmap and button into the toolbar */ 6583 /* Insert the single bitmap and button into the toolbar */
6860 0,0,0,0, 6875 0,0,0,0,
6861 DW_HWND_OBJECT, 6876 DW_HWND_OBJECT,
6862 (HMENU)(uintptr_t)id, 6877 (HMENU)(uintptr_t)id,
6863 DWInstance, 6878 DWInstance,
6864 NULL); 6879 NULL);
6880
6881 /* Disable visual styles by default */
6882 if(_SetWindowTheme)
6883 _SetWindowTheme(tmp, L"", L"");
6884
6865 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); 6885 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
6866 cinfo->fore = cinfo->back = -1; 6886 cinfo->fore = cinfo->back = -1;
6867 cinfo->pOldProc = SubclassWindow(tmp, _BtProc); 6887 cinfo->pOldProc = SubclassWindow(tmp, _BtProc);
6868 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); 6888 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
6869 dw_window_set_font(tmp, DefaultFont); 6889 dw_window_set_font(tmp, DefaultFont);
6961 0,0,0,0, 6981 0,0,0,0,
6962 DW_HWND_OBJECT, 6982 DW_HWND_OBJECT,
6963 (HMENU)(uintptr_t)id, 6983 (HMENU)(uintptr_t)id,
6964 DWInstance, 6984 DWInstance,
6965 NULL); 6985 NULL);
6986
6987 /* Disable visual styles by default */
6988 if(_SetWindowTheme)
6989 _SetWindowTheme(tmp, L"", L"");
6990
6966 cinfo->pOldProc = SubclassWindow(tmp, _BtProc); 6991 cinfo->pOldProc = SubclassWindow(tmp, _BtProc);
6967 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); 6992 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
6968 dw_window_set_data(tmp, "_dw_checkbox", DW_INT_TO_POINTER(1)); 6993 dw_window_set_data(tmp, "_dw_checkbox", DW_INT_TO_POINTER(1));
6969 dw_window_set_font(tmp, DefaultFont); 6994 dw_window_set_font(tmp, DefaultFont);
6970 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT); 6995 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);