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/alf.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'alf/alf.cpp') diff --git a/alf/alf.cpp b/alf/alf.cpp index deffd1a..30a998c 100644 --- a/alf/alf.cpp +++ b/alf/alf.cpp @@ -174,16 +174,24 @@ ALF_GetModalResult(HWND win) } int -ALF_CentipointsToPixels(HWND win, int cptValue) +ALF_CentipointsToPixels(int cptValue, int dpi) { - return (int)SendMessage(win, ALF_WM_CENTIPOINTTOPX, (WPARAM)cptValue, 0); + return MulDiv(cptValue, dpi, 7200); +} + +int +ALF_GetDpi(HWND window) +{ + return (int)SendMessage(window, ALF_WM_GETDPI, 0, 0); } void ALF_ResizeWindow(HWND win, int cptWidth, int cptHeight) { - int pxwidth = ALF_CentipointsToPixels(win, cptWidth); - int pxheight = ALF_CentipointsToPixels(win, cptHeight); + int dpi = ALF_GetDpi(win); + + int pxwidth = ALF_CentipointsToPixels(cptWidth, dpi); + int pxheight = ALF_CentipointsToPixels(cptHeight, dpi); ALF_ResizeWindowPx(win, pxwidth, pxheight); } @@ -408,7 +416,7 @@ ALF_ShouldMessageBubble(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) if (!GetParent(hwnd)) return FALSE; - return msg == ALF_WM_CENTIPOINTTOPX + return msg == ALF_WM_GETDPI || msg == WM_COMMAND || msg == WM_NOTIFY || msg == WM_MEASUREITEM || msg == WM_DRAWITEM || msg == WM_CTLCOLORBTN || msg == WM_CTLCOLOREDIT -- cgit v1.2.3