Fixed compiler warnings. Stack works!
This commit is contained in:
parent
42204af086
commit
12021269b7
|
@ -60,15 +60,15 @@ void resize(uiControl *control, HWND parent, RECT r)
|
||||||
{
|
{
|
||||||
uiSizing d;
|
uiSizing d;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
HFONT prevFont;
|
HFONT prevfont;
|
||||||
TEXTMETRICW tm;
|
TEXTMETRICW tm;
|
||||||
SIZE size;
|
SIZE size;
|
||||||
|
|
||||||
dc = GetDC(parent);
|
dc = GetDC(parent);
|
||||||
if (dc == NULL)
|
if (dc == NULL)
|
||||||
logLastError("error getting DC for preferred size calculations");
|
logLastError("error getting DC for preferred size calculations");
|
||||||
prevFont = (HFONT) SelectObject(dc, hMessageFont);
|
prevfont = (HFONT) SelectObject(dc, hMessageFont);
|
||||||
if (prevFont == NULL)
|
if (prevfont == NULL)
|
||||||
logLastError("error loading control font into device context for preferred size calculation");
|
logLastError("error loading control font into device context for preferred size calculation");
|
||||||
if (GetTextMetricsW(dc, &tm) == 0)
|
if (GetTextMetricsW(dc, &tm) == 0)
|
||||||
logLastError("error getting text metrics for preferred size calculations");
|
logLastError("error getting text metrics for preferred size calculations");
|
||||||
|
@ -77,7 +77,7 @@ void resize(uiControl *control, HWND parent, RECT r)
|
||||||
d.baseX = (int) ((size.cx / 26 + 1) / 2);
|
d.baseX = (int) ((size.cx / 26 + 1) / 2);
|
||||||
d.baseY = (int) tm.tmHeight;
|
d.baseY = (int) tm.tmHeight;
|
||||||
d.internalLeading = tm.tmInternalLeading;
|
d.internalLeading = tm.tmInternalLeading;
|
||||||
if (SelectObject(dc, prevFont) != hMessageFont)
|
if (SelectObject(dc, prevfont) != hMessageFont)
|
||||||
logLastError("error restoring previous font into device context after preferred size calculations");
|
logLastError("error restoring previous font into device context after preferred size calculations");
|
||||||
if (ReleaseDC(parent, dc) == 0)
|
if (ReleaseDC(parent, dc) == 0)
|
||||||
logLastError("error releasing DC for preferred size calculations");
|
logLastError("error releasing DC for preferred size calculations");
|
||||||
|
|
|
@ -20,7 +20,7 @@ static void loadLastError(uiInitError *err, const char *message)
|
||||||
le = GetLastError();
|
le = GetLastError();
|
||||||
// TODO FormatMessageW() it
|
// TODO FormatMessageW() it
|
||||||
// TODO make sure argument is right; _snprintf_s() isn't supported on Windows XP
|
// TODO make sure argument is right; _snprintf_s() isn't supported on Windows XP
|
||||||
sprintf(err->failbuf, 256, "error %s (last error %I32u)", message, le);
|
snprintf(err->failbuf, 256, "error %s (last error %I32u)", message, le);
|
||||||
err->msg = err->failbuf;
|
err->msg = err->failbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ int main(int argc, char *argv[])
|
||||||
uiWindowSetChild(w, stack);
|
uiWindowSetChild(w, stack);
|
||||||
|
|
||||||
button2 = uiNewButton("Change Me");
|
button2 = uiNewButton("Change Me");
|
||||||
uiButtonOnClicked(button, onClicked2, NULL);
|
uiButtonOnClicked(button2, onClicked2, NULL);
|
||||||
|
|
||||||
button = uiNewButton("Click Me");
|
button = uiNewButton("Click Me");
|
||||||
uiButtonOnClicked(button, onClicked, button2);
|
uiButtonOnClicked(button, onClicked, button2);
|
||||||
|
|
|
@ -24,6 +24,7 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd)
|
||||||
WCHAR *text;
|
WCHAR *text;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
HFONT prevfont;
|
HFONT prevfont;
|
||||||
|
SIZE size;
|
||||||
|
|
||||||
// TODO check for error
|
// TODO check for error
|
||||||
len = GetWindowTextLengthW(hwnd);
|
len = GetWindowTextLengthW(hwnd);
|
||||||
|
@ -32,17 +33,17 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd)
|
||||||
text = (WCHAR *) uiAlloc((len + 1) * sizeof (WCHAR));
|
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
|
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()");
|
logLastError("error getting window text in uiWindowsWindowTextWidth()");
|
||||||
dc = GetDC(parent);
|
dc = GetDC(hwnd);
|
||||||
if (dc == NULL)
|
if (dc == NULL)
|
||||||
logLastError("error getting DC in uiWindowsWindowTextWidth()");
|
logLastError("error getting DC in uiWindowsWindowTextWidth()");
|
||||||
prevFont = (HFONT) SelectObject(dc, hMessageFont);
|
prevfont = (HFONT) SelectObject(dc, hMessageFont);
|
||||||
if (prevFont == NULL)
|
if (prevfont == NULL)
|
||||||
logLastError("error loading control font into device context in uiWindowsWindowTextWidth()");
|
logLastError("error loading control font into device context in uiWindowsWindowTextWidth()");
|
||||||
if (GetTextExtentPoint32W(dc, text, len, &size) == 0)
|
if (GetTextExtentPoint32W(dc, text, len, &size) == 0)
|
||||||
logLastError("error getting text extent point in uiWindowsWindowTextWidth()");
|
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()");
|
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()");
|
logLastError("error releasing DC in uiWindowsWindowTextWidth()");
|
||||||
uiFree(text);
|
uiFree(text);
|
||||||
return size.cx;
|
return size.cx;
|
||||||
|
|
Loading…
Reference in New Issue