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;
|
||||
HBITMAP bitmap, prevbitmap;
|
||||
HBRUSH brush;
|
||||
DWORD le;
|
||||
|
||||
parent = hwnd;
|
||||
for (;;) {
|
||||
|
@ -61,13 +60,7 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc)
|
|||
if (GetWindowRect(hwnd, &r) == 0)
|
||||
logLastError("error getting control's window rect in getControlBackgroundBrush()");
|
||||
// the above is a window rect in screen coordinates; convert to parent coordinates
|
||||
SetLastError(0);
|
||||
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()");
|
||||
}
|
||||
mapWindowRect(NULL, parent, &r);
|
||||
if (SetBrushOrgEx(dc, -r.left, -r.top, NULL) == 0)
|
||||
logLastError("error setting brush origin in getControlBackgroundBrush()");
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ extern HBRUSH hollowBrush;
|
|||
|
||||
// util.c
|
||||
extern int windowClassOf(HWND, ...);
|
||||
extern void mapWindowRect(HWND, HWND, RECT *);
|
||||
|
||||
// text.c
|
||||
extern WCHAR *toUTF16(const char *);
|
||||
|
|
|
@ -81,3 +81,17 @@ void complain(const char *fmt, ...)
|
|||
va_end(ap);
|
||||
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