From 520cf456ddca96328c0e51e9ee81db10006f248d Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Fri, 28 Dec 2018 22:14:07 +0100 Subject: different method for button margin this one works with WM_CLIPCHILDREN, which we intend to make default --- alf/alfbutton.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'alf/alfbutton.cpp') diff --git a/alf/alfbutton.cpp b/alf/alfbutton.cpp index b32831a..0723563 100644 --- a/alf/alfbutton.cpp +++ b/alf/alfbutton.cpp @@ -52,21 +52,19 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT SelectFont(hdc, oldFont); ReleaseDC(hwnd, hdc); - } else if (uMsg == WM_NCCALCSIZE) { - /* HACK: a themed button contains a 1px margin. An unthemed button - * does not, so we add one by shrinking the client area */ - RECT *r = (RECT *)lParam; + } else if (uMsg == ALF_WM_APPLYSIZE) { + // HACK: a themed button contains a 1px margin. An unthemed button + // does not, so we add one. - int retval = app->compatFn->DefSubclassProc(hwnd, uMsg, wParam, lParam); + RECT *p = (RECT *)lParam; - if (!app->compatFn->IsAppThemed()) { - r->top += 1; - r->bottom -= 1; - } + int padding = app->compatFn->IsAppThemed() ? 0 : 1; - return retval; - } else if (uMsg == WM_THEMECHANGED) { - SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED); + return (LRESULT)DeferWindowPos((HDWP)wParam, + hwnd, NULL, + p->left, p->top + padding, + p->right - p->left, p->bottom - p->top - 2*padding, + SWP_NOZORDER|SWP_NOACTIVATE); } return app->compatFn->DefSubclassProc(hwnd, uMsg, wParam, lParam); @@ -97,7 +95,7 @@ ALF_AddButton(HWND win, WORD id, UINT x, UINT y, const WCHAR *text) p.y = y; p.width = 5625; p.height = 0; - p.flags = ALF_QUERYSIZE | ALF_MESSAGEFONT; + p.flags = ALF_QUERYSIZE | ALF_MESSAGEFONT | ALF_APPLYSIZE; ALF_AddWidgetEx(win, &p); -- cgit v1.2.3