From 7eefb8a250e263b6e02b44dcaa2c841eee385187 Mon Sep 17 00:00:00 2001 From: Alex Kompel Date: Mon, 13 Apr 2015 23:29:02 -0700 Subject: [PATCH] win32_gui: use AdjustWindowRect to get more accurate measurement of status window --- win/win32/mhstatus.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/win/win32/mhstatus.c b/win/win32/mhstatus.c index b81988ad5..6cbf99e15 100644 --- a/win/win32/mhstatus.c +++ b/win/win32/mhstatus.c @@ -194,20 +194,24 @@ void mswin_status_window_size (HWND hWnd, LPSIZE sz) HDC hdc; PNHStatusWindow data; RECT rt; - GetWindowRect(hWnd, &rt); - sz->cx = rt.right - rt.left; - sz->cy = rt.bottom - rt.top; + SIZE text_sz; + + GetClientRect(hWnd, &rt); data = (PNHStatusWindow)GetWindowLong(hWnd, GWL_USERDATA); if(data) { hdc = GetDC(hWnd); saveFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE)); + GetTextExtentPoint32(hdc, _T("W"), 1, &text_sz); GetTextMetrics(hdc, &tm); - sz->cy = tm.tmHeight * NHSW_LINES + 2*GetSystemMetrics(SM_CYSIZEFRAME); + rt.bottom = rt.top + text_sz.cy*NHSW_LINES; SelectObject(hdc, saveFont); ReleaseDC(hWnd, hdc); } + AdjustWindowRect(&rt, GetWindowLong(hWnd, GWL_STYLE), FALSE); + sz->cx = rt.right - rt.left; + sz->cy = rt.bottom - rt.top; }