summaryrefslogtreecommitdiff
path: root/alf/alfbutton.cpp
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2018-12-28 22:14:07 +0100
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2018-12-28 22:14:07 +0100
commit520cf456ddca96328c0e51e9ee81db10006f248d (patch)
tree6ca0e49272de1f3e585da8cf928eb27fddb75018 /alf/alfbutton.cpp
parent774cbae7824e4410b5523762496c0ddb35da13d8 (diff)
different method for button margin
this one works with WM_CLIPCHILDREN, which we intend to make default
Diffstat (limited to 'alf/alfbutton.cpp')
-rw-r--r--alf/alfbutton.cpp24
1 files changed, 11 insertions, 13 deletions
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);