diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-07 19:36:46 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-07 19:36:46 -0400 |
| commit | 12021269b7789a680bf1286616505a7546f26d93 (patch) | |
| tree | df71575b471588858fa1b6149733b079e5a5a06d /new/util_windows.c | |
| parent | 42204af0865cd6c712b1f9b1e20694c1fc971503 (diff) | |
Fixed compiler warnings. Stack works!
Diffstat (limited to 'new/util_windows.c')
| -rw-r--r-- | new/util_windows.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/new/util_windows.c b/new/util_windows.c index c0d3d6c..8e0532b 100644 --- a/new/util_windows.c +++ b/new/util_windows.c @@ -24,6 +24,7 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd) WCHAR *text; HDC dc; HFONT prevfont; + SIZE size; // TODO check for error len = GetWindowTextLengthW(hwnd); @@ -32,17 +33,17 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd) text = (WCHAR *) uiAlloc((len + 1) * sizeof (WCHAR)); if (GetWindowText(hwnd, text, len + 1) == 0) // should only happen on error given explicit test for len == 0 above logLastError("error getting window text in uiWindowsWindowTextWidth()"); - dc = GetDC(parent); + dc = GetDC(hwnd); if (dc == NULL) logLastError("error getting DC in uiWindowsWindowTextWidth()"); - prevFont = (HFONT) SelectObject(dc, hMessageFont); - if (prevFont == NULL) + prevfont = (HFONT) SelectObject(dc, hMessageFont); + if (prevfont == NULL) logLastError("error loading control font into device context in uiWindowsWindowTextWidth()"); if (GetTextExtentPoint32W(dc, text, len, &size) == 0) logLastError("error getting text extent point in uiWindowsWindowTextWidth()"); - if (SelectObject(dc, prevFont) != hMessageFont) + if (SelectObject(dc, prevfont) != hMessageFont) logLastError("error restoring previous font into device context in uiWindowsWindowTextWidth()"); - if (ReleaseDC(parent, dc) == 0) + if (ReleaseDC(hwnd, dc) == 0) logLastError("error releasing DC in uiWindowsWindowTextWidth()"); uiFree(text); return size.cx; |
