Added a wrapper around MapWindowRect() to simplify error handling. This will be needed for future changes to windows/container.c.
This commit is contained in:
parent
047d5aaa4d
commit
93ead4043e
|
@ -21,7 +21,6 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc)
|
||||||
HDC cdc;
|
HDC cdc;
|
||||||
HBITMAP bitmap, prevbitmap;
|
HBITMAP bitmap, prevbitmap;
|
||||||
HBRUSH brush;
|
HBRUSH brush;
|
||||||
DWORD le;
|
|
||||||
|
|
||||||
parent = hwnd;
|
parent = hwnd;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -61,13 +60,7 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc)
|
||||||
if (GetWindowRect(hwnd, &r) == 0)
|
if (GetWindowRect(hwnd, &r) == 0)
|
||||||
logLastError("error getting control's window rect in getControlBackgroundBrush()");
|
logLastError("error getting control's window rect in getControlBackgroundBrush()");
|
||||||
// the above is a window rect in screen coordinates; convert to parent coordinates
|
// the above is a window rect in screen coordinates; convert to parent coordinates
|
||||||
SetLastError(0);
|
mapWindowRect(NULL, parent, &r);
|
||||||
if (MapWindowRect(NULL, parent, &r) == 0) {
|
|
||||||
le = GetLastError();
|
|
||||||
SetLastError(le); // just to be safe
|
|
||||||
if (le != 0)
|
|
||||||
logLastError("error getting coordinates to change brush origin to in getControlBackgroundBrush()");
|
|
||||||
}
|
|
||||||
if (SetBrushOrgEx(dc, -r.left, -r.top, NULL) == 0)
|
if (SetBrushOrgEx(dc, -r.left, -r.top, NULL) == 0)
|
||||||
logLastError("error setting brush origin in getControlBackgroundBrush()");
|
logLastError("error setting brush origin in getControlBackgroundBrush()");
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ extern HBRUSH hollowBrush;
|
||||||
|
|
||||||
// util.c
|
// util.c
|
||||||
extern int windowClassOf(HWND, ...);
|
extern int windowClassOf(HWND, ...);
|
||||||
|
extern void mapWindowRect(HWND, HWND, RECT *);
|
||||||
|
|
||||||
// text.c
|
// text.c
|
||||||
extern WCHAR *toUTF16(const char *);
|
extern WCHAR *toUTF16(const char *);
|
||||||
|
|
|
@ -81,3 +81,17 @@ void complain(const char *fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wrapper around MapWindowRect() that handles the complex error handling
|
||||||
|
void mapWindowRect(HWND from, HWND to, RECT *r)
|
||||||
|
{
|
||||||
|
DWORD le;
|
||||||
|
|
||||||
|
SetLastError(0);
|
||||||
|
if (MapWindowRect(from, to, r) == 0) {
|
||||||
|
le = GetLastError();
|
||||||
|
SetLastError(le); // just to be safe
|
||||||
|
if (le != 0)
|
||||||
|
logLastError("error calling MapWindowRect() in mapWindowRect()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue