]> granicus.if.org Git - nethack/commitdiff
win32_gui: use AdjustWindowRect to get more accurate measurement of status window
authorAlex Kompel <barbos+nethack@gmail.com>
Tue, 14 Apr 2015 06:29:02 +0000 (23:29 -0700)
committerAlex Kompel <barbos+nethack@gmail.com>
Tue, 14 Apr 2015 06:29:02 +0000 (23:29 -0700)
win/win32/mhstatus.c

index b81988ad5a4e948030755e82b013f5e5da990a6e..6cbf99e15100e55a5825a73ee5425026df85570b 100644 (file)
@@ -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;
 }