From 51daba89072cb66fe5e43015484a554555a40499 Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Thu, 23 Apr 2020 15:07:21 +0200 Subject: changed DPI handling: dpi is now pushed into every control and saved there --- alf/alfbutton.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'alf/alfbutton.cpp') diff --git a/alf/alfbutton.cpp b/alf/alfbutton.cpp index ddf607d..579fdce 100644 --- a/alf/alfbutton.cpp +++ b/alf/alfbutton.cpp @@ -19,6 +19,7 @@ typedef struct { UINT itemStateCurrent; DWORD uxDefaultAnimationDuration; BOOL uxIsDefaultAnimating; + int dpi; } ALFButtonPriv; static void CALLBACK @@ -294,9 +295,9 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT ALF_Free(textbuf); int xpadding = ALF_Compat_GetSystemMetricsForDpi(SM_CXEDGE, - (UINT)ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 6; + (UINT)priv->dpi) * 2 + 6; int ypadding = ALF_Compat_GetSystemMetricsForDpi(SM_CYEDGE, - (UINT)ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 4; + (UINT)priv->dpi) * 2 + 4; SIZE *pSize = (SIZE*)(void*)lParam; if (pSize->cx < r.right - r.left + xpadding) { @@ -473,6 +474,10 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT ALF_InvalidateLayout(GetParent(hwnd)); } else if (uMsg == WM_SETFONT) { ALF_InvalidateLayout(GetParent(hwnd)); + } else if (uMsg == ALF_WM_DPICHANGE) { + priv->dpi = (int)lParam; + ALF_InvalidateLayout(GetParent(hwnd)); + return TRUE; } return ALF_Compat_DefSubclassProc(hwnd, uMsg, wParam, lParam); @@ -494,12 +499,13 @@ ALF_AddButton(HWND win, WORD id, int x, int y, const TCHAR *text) ALFButtonPriv *priv = ALF_New(ALFButtonPriv, 1); priv->uxStateCurrent = -1; priv->uxStatePrev = -1; + priv->dpi = 96; ALF_Compat_SetWindowSubclass(hwndButton, ALF__ButtonSubclassProc, 0, (DWORD_PTR)priv); SendMessage(hwndButton, WM_THEMECHANGED, 0, 0); - ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT); + ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_SENDDPICHANGE); return hwndButton; } -- cgit v1.2.3