summaryrefslogtreecommitdiff
path: root/new/util_windows.c
diff options
context:
space:
mode:
Diffstat (limited to 'new/util_windows.c')
-rw-r--r--new/util_windows.c11
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;