Skip to content

Commit

Permalink
further fruitless experiments (~#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Apr 15, 2020
1 parent 3224ed5 commit d93e92a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/winctrls.c
Expand Up @@ -13,6 +13,9 @@
#define _WTYPES_H
#define _OLE2_H
#include <commdlg.h>
#ifdef darken_dialog_elements
#include <commctrl.h> // Subclass
#endif


/*
Expand Down Expand Up @@ -54,6 +57,21 @@ ctrlposinit(ctrlpos * cp, HWND wnd, int leftborder, int rightborder,
cp->width -= leftborder + rightborder;
}

#ifdef darken_dialog_elements
static LRESULT CALLBACK
ctl_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uid, DWORD_PTR data)
{
(void)uid; (void)data;
switch (msg) {
//when WM_ERASEBKGND:
// makes things worse (flickering, invisible items)
//when 0x0090 or 0x00F1 or 0x00F4 or 0x0143 or 0x014B:
// these also occur
}
return DefSubclassProc(hwnd, msg, wp, lp);
}
#endif

static HWND
doctl(control * ctrl,
ctrlpos * cp, RECT r,
Expand Down Expand Up @@ -97,6 +115,8 @@ doctl(control * ctrl,
#ifdef darken_dialog_elements
// apply dark mode to dialog buttons
win_dark_mode(ctl);
// try to darken further elements
SetWindowSubclass(ctl, ctl_proc, 0, 0);
#endif
#ifdef debug_widgets
printf("%8p %s %d '%s'\n", ctl, class, exstyle, text);
Expand Down
18 changes: 15 additions & 3 deletions src/windialog.c
Expand Up @@ -412,13 +412,18 @@ tree_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uid, DWORD_PTR dat
colour bg = RGB(22, 22, 22);
/// ... retrieve bg from DarkMode_Explorer theme
switch (msg) {
when WM_ERASEBKGND: // handled via WM_CTLCOLORDLG above
when WM_ERASEBKGND: // darken treeview background
if (support_dark_mode) {
HDC hdc = (HDC)wp;
RECT rc;
GetClientRect(wnd, &rc);
return FillRect(hdc, &rc, CreateSolidBrush(bg));
HBRUSH br = CreateSolidBrush(bg);
int res = FillRect(hdc, &rc, br);
DeleteObject(br);
return res;
}
//when 0x1100 or 0x110A or 0x110B or 0x110C or 0x112A or 0x112D or 0x113E or 0x2100:
// these also occur
}
return DefSubclassProc(hwnd, msg, wp, lp);
}
Expand Down Expand Up @@ -580,20 +585,27 @@ config_dialog_proc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
or WM_CTLCOLORBTN // button borders; for buttons, see doctl
or WM_CTLCOLOREDIT // popup items
or WM_CTLCOLORLISTBOX: // popup menu
// or WM_CTLCOLORMSGBOX or WM_CTLCOLORSCROLLBAR ?
// setting fg fails for WM_CTLCOLORSTATIC
if (support_dark_mode) {
HDC hdc = (HDC)wParam;
SetTextColor(hdc, fg);
SetBkColor(hdc, bg);
return (INT_PTR)CreateSolidBrush(bg);
}
//when 0x0090 or 0x00F1 or 0x00F4 or 0x0143 or 0x014B:
// these also occur

#ifdef draw_dialog_bg
when WM_ERASEBKGND: // handled via WM_CTLCOLORDLG above
if (support_dark_mode) {
HDC hdc = (HDC)wParam;
RECT rc;
GetClientRect(wnd, &rc);
return FillRect(hdc, &rc, CreateSolidBrush(bg));
HBRUSH br = CreateSolidBrush(bg);
int res = FillRect(hdc, &rc, br);
DeleteObject(br);
return res;
}
#endif
#endif
Expand Down

0 comments on commit d93e92a

Please sign in to comment.