+ chg: trying to set background of dialog boxes

This commit is contained in:
RaiKoHoff 2020-09-02 17:32:29 +02:00
parent 366545b08d
commit 5546600ae2
3 changed files with 83 additions and 17 deletions

View File

@ -247,6 +247,22 @@ static INT_PTR CALLBACK _InfoBoxLngDlgProc(HWND hwnd, UINT umsg, WPARAM wParam,
SetWindowLayoutRTL(hwnd, (lpMsgBox->uType & MB_RTLREADING));
if (IsDarkModeSupported() && CheckDarkModeEnabled())
{
for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
HWND const hBtn = GetDlgItem(hwnd, btn);
if (hBtn) {
SetExplorerTheme(hBtn);
}
}
SetExplorerTheme(hwnd);
}
HDC const hdc = GetDC(hwnd);
SetTextColor(hdc, Globals.rgbDarkTextColor);
SetBkColor(hdc, Globals.rgbDarkBkgColor);
ReleaseDC(hwnd, hdc);
dpi = Scintilla_GetWindowDPI(hwnd);
int const scxb = ScaleIntByDPI(GetSystemMetrics(SM_CXICON), dpi.x);
@ -308,12 +324,66 @@ static INT_PTR CALLBACK _InfoBoxLngDlgProc(HWND hwnd, UINT umsg, WPARAM wParam,
}
return !0;
case WM_DESTROY:
if (hIconBmp) {
DeleteObject(hIconBmp);
}
return !0;
//case WM_ERASEBKGND:
// if (IsDarkModeSupported() && CheckDarkModeEnabled()) {
// HDC const hdc = (HDC)wParam;
// SelectObject((HDC)wParam, s_hbrWndDarkBackground);
// RECT rc;
// GetClientRect(hwnd, &rc);
// SetMapMode(hdc, MM_ANISOTROPIC);
// SetWindowExtEx(hdc, 100, 100, NULL);
// SetViewportExtEx(hdc, rc.right, rc.bottom, NULL);
// FillRect(hdc, &rc, s_hbrWndDarkBackground);
// }
// return !0;
case WM_CTLCOLOR:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC: {
if (IsDarkModeSupported() && CheckDarkModeEnabled()) {
HDC const hdc = (HDC)wParam;
SetTextColor(hdc, Globals.rgbDarkTextColor);
SetBkColor(hdc, Globals.rgbDarkBkgColor);
return (INT_PTR)s_hbrWndDarkBackground;
}
} break;
case WM_SETTINGCHANGE:
if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
SendMessageW(hwnd, WM_THEMECHANGED, 0, 0);
}
break;
case WM_THEMECHANGED:
if (IsDarkModeSupported())
{
bool const darkModeEnabled = CheckDarkModeEnabled();
AllowDarkModeForWindow(hwnd, darkModeEnabled);
RefreshTitleBarThemeColor(hwnd);
for (int btn = IDOK; btn <= IDCONTINUE; ++btn) {
HWND const hBtn = GetDlgItem(hwnd, btn);
if (hBtn) {
AllowDarkModeForWindow(hBtn, darkModeEnabled);
SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
}
}
UpdateWindow(hwnd);
}
break;
case WM_COMMAND:
{
LPINFOBOXLNG const lpMsgBox = (LPINFOBOXLNG)GetWindowLongPtr(hwnd, DWLP_USER);
@ -701,14 +771,10 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
//~SetWindowLayoutRTL(hwnd, Settings.DialogsLayoutRTL);
if (!hbrBkgnd) {
hbrBkgnd = CreateSolidBrush(Globals.rgbDarkBkgColor);
}
if (IsDarkModeSupported() && CheckDarkModeEnabled()) {
SetExplorerTheme(GetDlgItem(hwnd, IDOK));
SetExplorerTheme(GetDlgItem(hwnd, IDC_COPYVERSTRG));
PostMessage(hwnd, WM_THEMECHANGED, 0, 0);
SetExplorerTheme(hwnd);
}
dpi = Scintilla_GetWindowDPI(hwnd);
@ -820,10 +886,6 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
DeleteObject(hVersionFont);
hVersionFont = NULL;
}
if (hbrBkgnd) {
DeleteObject(hbrBkgnd);
hbrBkgnd = NULL;
}
break;
case WM_DPICHANGED:
@ -868,6 +930,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
break;
case WM_CTLCOLOR:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
@ -875,7 +938,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
HDC hdc = (HDC)wParam;
SetTextColor(hdc, Globals.rgbDarkTextColor);
SetBkColor(hdc, Globals.rgbDarkBkgColor);
return (INT_PTR)hbrBkgnd;
return (INT_PTR)s_hbrWndDarkBackground;
}
}
break;
@ -1888,7 +1951,6 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR
&shfi, sizeof(SHFILEINFO), SHGFI_LARGEICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES),
LVSIL_NORMAL);
//SetExplorerTheme(GetDlgItem(hwnd,IDC_FILEMRU));
ListView_SetExtendedListViewStyle(hwndIL, /*LVS_EX_FULLROWSELECT|*/ LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
ListView_InsertColumn(hwndIL, 0, &lvc);

View File

@ -52,7 +52,7 @@
//
// ============================================================================
static HBRUSH s_hbrBkgnd = NULL;
HBRUSH s_hbrWndDarkBackground = NULL;
// ----------------------------------------------------------------------------
@ -601,6 +601,8 @@ static void _InitGlobals()
ZeroMemory(&(Globals.fvCurFile), sizeof(FILEVARS));
InitDarkMode();
s_hbrWndDarkBackground = CreateSolidBrush(Globals.rgbDarkBkgColor);
Globals.WindowsBuildNumber = GetWindowsBuildNumber();
Globals.hDlgIcon256 = NULL;
@ -769,6 +771,10 @@ static void _CleanUpResources(const HWND hwnd, bool bIsInitialized)
UnregisterClass(s_wchWndClass, Globals.hInstance);
}
if (s_hbrWndDarkBackground) {
DeleteObject(s_hbrWndDarkBackground);
}
if (s_lpOrigFileArg) {
FreeMem(s_lpOrigFileArg);
s_lpOrigFileArg = NULL;
@ -1292,7 +1298,7 @@ bool InitApplication(HINSTANCE hInstance)
wc.hInstance = hInstance;
wc.hIcon = Globals.hDlgIcon256;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW); //(HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MUI_MAINMENU);
wc.lpszClassName = s_wchWndClass;
@ -2064,10 +2070,6 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam)
{
UNUSED(wParam);
if (!s_hbrBkgnd) {
s_hbrBkgnd = CreateSolidBrush(Globals.rgbDarkBkgColor);
}
if (IsDarkModeSupported()) {
AllowDarkModeForWindow(hwnd, CheckDarkModeEnabled());
RefreshTitleBarThemeColor(hwnd);
@ -2381,6 +2383,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance)
// @@@ §§§ no effect:
//HDC const hdcTB = GetWindowDC(Globals.hwndToolbar);
////~SelectObject(hdcTB, s_hbrWndDarkBackground);
//SetBkColor(hdcTB, Globals.rgbDarkBkgColor);
//ReleaseDC(Globals.hwndToolbar, hdcTB);

View File

@ -273,6 +273,7 @@ typedef enum
#define OCCURRENCE_MARKER_BITMASK() (bitmask32_n(MARKER_NP3_BOOKMARK + 1) & ~(1 << MARKER_NP3_OCCURRENCE))
extern LPCWSTR WordBookMarks[];
extern HBRUSH s_hbrWndDarkBackground;
// --------------------------------------------------------------------------