More Windows popover error checking.
This commit is contained in:
parent
4777c0c309
commit
2420e3ea2a
|
@ -77,6 +77,8 @@ HRGN makePopoverRegion(HDC dc, LONG width, LONG height)
|
||||||
if (EndPath(dc) == 0)
|
if (EndPath(dc) == 0)
|
||||||
xpanic("error ending path for Popover shape", GetLastError());
|
xpanic("error ending path for Popover shape", GetLastError());
|
||||||
region = PathToRegion(dc);
|
region = PathToRegion(dc);
|
||||||
|
if (region == NULL)
|
||||||
|
xpanic("error converting Popover shape path to region", GetLastError());
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,25 +99,33 @@ LRESULT CALLBACK popoverproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
width = r.right - r.left;
|
width = r.right - r.left;
|
||||||
height = r.bottom - r.top;
|
height = r.bottom - r.top;
|
||||||
dc = GetWindowDC(hwnd);
|
dc = GetWindowDC(hwnd);
|
||||||
// TODO error
|
if (dc == NULL)
|
||||||
|
xpanic("error getting Popover window DC for drawing border", GetLastError());
|
||||||
region = makePopoverRegion(dc, width, height);
|
region = makePopoverRegion(dc, width, height);
|
||||||
// TODO isolate the class brush to a constant
|
// TODO isolate the class brush to a constant
|
||||||
FillRgn(dc, region, GetSysColorBrush(COLOR_BTNFACE));
|
// TODO object errors (or switch to path functions?)
|
||||||
FrameRgn(dc, region, GetStockObject(BLACK_PEN), 1, 1);
|
if (FillRgn(dc, region, GetSysColorBrush(COLOR_BTNFACE)) == 0)
|
||||||
DeleteObject(region);
|
xpanic("error drawing Popover background", GetLastError());
|
||||||
ReleaseDC(hwnd, dc);
|
if (FrameRgn(dc, region, GetStockObject(BLACK_PEN), 1, 1) == 0)
|
||||||
|
xpanic("error drawing Popover border", GetLastError());
|
||||||
|
if (DeleteObject(region) == 0)
|
||||||
|
xpanic("error deleting Popover shape region", GetLastError());
|
||||||
|
if (ReleaseDC(hwnd, dc) == 0)
|
||||||
|
xpanic("error releasing Popover window DC for shape drawing", GetLastError());
|
||||||
return 0;
|
return 0;
|
||||||
case WM_WINDOWPOSCHANGED:
|
case WM_WINDOWPOSCHANGED:
|
||||||
// this must be here; if it's in WM_NCPAINT weird things happen (see http://stackoverflow.com/questions/26288303/why-is-my-client-rectangle-drawing-behaving-bizarrely-pictures-provided-if-i-t)
|
// this must be here; if it's in WM_NCPAINT weird things happen (see http://stackoverflow.com/questions/26288303/why-is-my-client-rectangle-drawing-behaving-bizarrely-pictures-provided-if-i-t)
|
||||||
wp = (WINDOWPOS *) lParam;
|
wp = (WINDOWPOS *) lParam;
|
||||||
if ((wp->flags & SWP_NOSIZE) == 0) {
|
if ((wp->flags & SWP_NOSIZE) == 0) {
|
||||||
dc = GetWindowDC(hwnd);
|
dc = GetWindowDC(hwnd);
|
||||||
// TODO error
|
if (dc == NULL)
|
||||||
|
xpanic("error getting Popover window DC for reshaping", GetLastError());
|
||||||
region = makePopoverRegion(dc, wp->cx, wp->cy);
|
region = makePopoverRegion(dc, wp->cx, wp->cy);
|
||||||
if (SetWindowRgn(hwnd, region, TRUE) == 0)
|
if (SetWindowRgn(hwnd, region, TRUE) == 0)
|
||||||
xpanic("error setting Popover shape", GetLastError());
|
xpanic("error setting Popover shape", GetLastError());
|
||||||
// don't delete the region; the window manager owns it now
|
// don't delete the region; the window manager owns it now
|
||||||
ReleaseDC(hwnd, dc);
|
if (ReleaseDC(hwnd, dc) == 0)
|
||||||
|
xpanic("error releasing Popover window DC for reshaping", GetLastError());
|
||||||
}
|
}
|
||||||
break; // defer to DefWindowProc()
|
break; // defer to DefWindowProc()
|
||||||
case WM_NCCALCSIZE:
|
case WM_NCCALCSIZE:
|
||||||
|
@ -125,7 +135,6 @@ LRESULT CALLBACK popoverproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
if (wParam != FALSE)
|
if (wParam != FALSE)
|
||||||
r = &np->rgrc[0];
|
r = &np->rgrc[0];
|
||||||
printf("%d | %d %d %d %d\n", wParam, r->left, r->top, r->right, r->bottom);
|
|
||||||
r->left++;
|
r->left++;
|
||||||
r->top++;
|
r->top++;
|
||||||
r->right--;
|
r->right--;
|
||||||
|
@ -134,12 +143,12 @@ LRESULT CALLBACK popoverproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
/* dc = BeginPaint(hwnd, &ps);
|
dc = BeginPaint(hwnd, &ps);
|
||||||
GetClientRect(hwnd, &r);
|
GetClientRect(hwnd, &r);
|
||||||
FillRect(dc, &r, GetSysColorBrush(COLOR_ACTIVECAPTION));
|
FillRect(dc, &r, GetSysColorBrush(COLOR_ACTIVECAPTION));
|
||||||
FrameRect(dc, &r, GetStockPen(WHITE_PEN));
|
FrameRect(dc, &r, GetStockPen(WHITE_PEN));
|
||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
*/ return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue