Disabled WM_PRINTCLIENT in uiContainer on Windows for now.

This commit is contained in:
Pietro Gagliardi 2015-05-05 14:37:25 -04:00
parent 4ba82c6eeb
commit 7f56079257
1 changed files with 15 additions and 13 deletions

View File

@ -13,10 +13,10 @@ struct container {
}; };
// see http://www.codeproject.com/Articles/5978/Correctly-drawn-themed-dialogs-in-WinXP // see http://www.codeproject.com/Articles/5978/Correctly-drawn-themed-dialogs-in-WinXP
static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc) static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc, RECT *hwndScreenRect)
{ {
HWND parent; HWND parent;
RECT r; RECT parentRect;
int class; int class;
HDC cdc; HDC cdc;
HBITMAP bitmap, prevbitmap; HBITMAP bitmap, prevbitmap;
@ -33,13 +33,13 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc)
} }
// TODO get client rect instead? // TODO get client rect instead?
if (GetWindowRect(parent, &r) == 0) if (GetWindowRect(parent, &parentRect) == 0)
logLastError("error getting parent's window rect in getControlBackgroundBrush()"); logLastError("error getting parent's window rect in getControlBackgroundBrush()");
cdc = CreateCompatibleDC(dc); cdc = CreateCompatibleDC(dc);
if (cdc == NULL) if (cdc == NULL)
logLastError("error creating compatible DC in getControlBackgroundBrush()"); logLastError("error creating compatible DC in getControlBackgroundBrush()");
bitmap = CreateCompatibleBitmap(dc, r.right - r.left, r.bottom - r.top); bitmap = CreateCompatibleBitmap(dc, parentRect.right - parentRect.left, parentRect.bottom - parentRect.top);
if (bitmap == NULL) if (bitmap == NULL)
logLastError("error creating compatible bitmap in getControlBackgroundBrush()"); logLastError("error creating compatible bitmap in getControlBackgroundBrush()");
prevbitmap = SelectObject(cdc, bitmap); prevbitmap = SelectObject(cdc, bitmap);
@ -57,11 +57,9 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc)
if (DeleteDC(cdc) == 0) if (DeleteDC(cdc) == 0)
logLastError("error deleting compatible DC in getControlBackgroundBrush()"); logLastError("error deleting compatible DC in getControlBackgroundBrush()");
if (GetWindowRect(hwnd, &r) == 0) // the given control rect is in screen coordinates; convert to parent coordinates
logLastError("error getting control's window rect in getControlBackgroundBrush()"); mapWindowRect(NULL, parent, hwndScreenRect);
// the above is a window rect in screen coordinates; convert to parent coordinates if (SetBrushOrgEx(dc, -hwndScreenRect->left, -hwndScreenRect->top, NULL) == 0)
mapWindowRect(NULL, parent, &r);
if (SetBrushOrgEx(dc, -r.left, -r.top, NULL) == 0)
logLastError("error setting brush origin in getControlBackgroundBrush()"); logLastError("error setting brush origin in getControlBackgroundBrush()");
return brush; return brush;
@ -75,7 +73,7 @@ static void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect)
// getControlBackgroundBrush() needs a screen rectangle // getControlBackgroundBrush() needs a screen rectangle
screenRect = *paintRect; screenRect = *paintRect;
mapWindowRect(hwnd, NULL, &screenRect); mapWindowRect(hwnd, NULL, &screenRect);
brush = getControlBackgroundBrush(hwnd, dc); brush = getControlBackgroundBrush(hwnd, dc, &screenRect);
prevbrush = SelectObject(dc, brush); prevbrush = SelectObject(dc, brush);
if (prevbrush == NULL) if (prevbrush == NULL)
logLastError("error selecting background brush into DC in paintContainerBackground()"); logLastError("error selecting background brush into DC in paintContainerBackground()");
@ -184,8 +182,10 @@ static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
if (textfieldReadOnly((HWND) lParam)) if (textfieldReadOnly((HWND) lParam))
return DefWindowProcW(hwnd, uMsg, wParam, lParam); return DefWindowProcW(hwnd, uMsg, wParam, lParam);
*/ if (SetBkMode((HDC) wParam, TRANSPARENT) == 0) */ if (SetBkMode((HDC) wParam, TRANSPARENT) == 0)
logLastError("error setting transparent background mode to controls in parentWndProc()"); logLastError("error setting transparent background mode to controls in containerWndProc()");
c->brush = getControlBackgroundBrush((HWND) lParam, (HDC) wParam); if (GetWindowRect((HWND) lParam, &r) == 0)
logLastError("error getting control's window rect in containerWndProc()");
c->brush = getControlBackgroundBrush((HWND) lParam, (HDC) wParam, &r);
return (LRESULT) (c->brush); return (LRESULT) (c->brush);
case WM_PAINT: case WM_PAINT:
if (cc == NULL) if (cc == NULL)
@ -198,7 +198,9 @@ static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
paintContainerBackground(c->hwnd, dc, &r); paintContainerBackground(c->hwnd, dc, &r);
EndPaint(c->hwnd, &ps); EndPaint(c->hwnd, &ps);
return 0; return 0;
case WM_PRINTCLIENT: // TODO the tab control uses this to draw the tab background
// but we have no idea where the tab is, so...
// case WM_PRINTCLIENT:
if (cc == NULL) if (cc == NULL)
break; break;
c = (struct container *) (uiControl(cc)->Internal); c = (struct container *) (uiControl(cc)->Internal);