summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alf/alf.cpp15
-rw-r--r--alf/alf.h5
-rw-r--r--alf/alfbutton.cpp24
3 files changed, 28 insertions, 16 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp
index 2f3af7c..e71e3a1 100644
--- a/alf/alf.cpp
+++ b/alf/alf.cpp
@@ -414,11 +414,16 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
if (msg == WM_DPICHANGED) {
ALF_UpdateFonts(hwnd);
- ALF_RecalculateLayout(hwnd);
+ ALF_CalculateSizes(priv);
RECT *r = (RECT*)lparam;
SetWindowPos(hwnd, NULL, r->left, r->top, r->right-r->left, r->bottom-r->top, SWP_NOACTIVATE|SWP_NOZORDER);
}
+ if (msg == WM_THEMECHANGED || msg == WM_SETTINGCHANGE) {
+ ALF_UpdateFonts(hwnd);
+ ALF_RecalculateLayout(hwnd);
+ }
+
if (msg == DM_GETDEFID) {
if (priv->defid == (WORD)-1) {
return 0;
@@ -606,11 +611,17 @@ ALF_CentipointsToPixels(HWND win, int cptValue)
}
void
-ALF_ResizeWindow(HWND win, UINT cptWidth, UINT cptHeight)
+ALF_ResizeWindow(HWND win, int cptWidth, int cptHeight)
{
int pxwidth = ALF_CentipointsToPixels(win, cptWidth);
int pxheight = ALF_CentipointsToPixels(win, cptHeight);
+ ALF_ResizeWindowPx(win, pxwidth, pxheight);
+}
+
+void
+ALF_ResizeWindowPx(HWND win, int pxwidth, int pxheight)
+{
MINMAXINFO tmp = {
{ 0, 0 },
{ pxwidth, pxheight },
diff --git a/alf/alf.h b/alf/alf.h
index 5540ebb..987874a 100644
--- a/alf/alf.h
+++ b/alf/alf.h
@@ -135,7 +135,10 @@ void
ALF_UpdateFonts(HWND win);
void
-ALF_ResizeWindow(HWND win, UINT cptWidth, UINT cptHeight);
+ALF_ResizeWindow(HWND win, int cptWidth, int cptHeight);
+
+void
+ALF_ResizeWindowPx(HWND win, int pxWidth, int pxHeight);
int
ALF_ShowModal(HWND win);
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);