From 1069c22d0da82ba81a9fb1242a808e0a65316b55 Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Sat, 23 May 2020 12:28:31 +0200 Subject: move checkbox into button --- alf/alflayout.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'alf/alflayout.cpp') diff --git a/alf/alflayout.cpp b/alf/alflayout.cpp index 0fa3473..470f728 100644 --- a/alf/alflayout.cpp +++ b/alf/alflayout.cpp @@ -214,8 +214,6 @@ ALF_Layout_CalcCheckboxSize(HWND hwndWindow, ALFLayout *layout, HWND hwndCheckbo { (void)hwndWindow; - int checkwidth = 12 * layout->dpi / 96 + 1; - HDC hDC = GetDC(hwndCheckbox); HFONT font = (HFONT)SendMessage(hwndCheckbox, WM_GETFONT, 0, 0); HFONT oldfont = SelectFont(hDC, font); @@ -230,11 +228,24 @@ ALF_Layout_CalcCheckboxSize(HWND hwndWindow, ALFLayout *layout, HWND hwndCheckbo int cx = 0; GetCharWidth(hDC, '0', '0', &cx); + int checkwidth = 12 * layout->dpi / 96 + 1; + int checkheight = checkwidth; + + if (!ALF_Compat_IsMinWindowsVersion(4, 0)) { + // 3.x-style checkboxes have the checkmark baseline-aligned + TEXTMETRIC tm; + ZeroMemory(&tm, sizeof(tm)); + + if (GetTextMetrics(hDC, &tm)) { + checkheight += tm.tmDescent; + } + } + cx += checkwidth + r.right - r.left; int cy = r.bottom - r.top; - if (checkwidth > cy) - cy = checkwidth; + if (checkheight > cy) + cy = checkheight; if (ps->cx < cx) ps->cx = cx; -- cgit v1.2.3