Post by JohnPost by Christian ASTORPost by JohnAnyone know how to do this? A search of Google and Usenet seems to
imply it's impossible, without possibly owner-drawing? Any ideas?
Subclassing - WM_PAINT - WM_PRINT
Okay... but I'm afraid I don't know how to do that. Are you perhaps
willing and able to provide an example, or give a bit more info that
will clue me in? Thanks. :)
For example, to change the background color to red, you can do =>
LRESULT OldDTPProc;
LRESULT CALLBACK NewDTPProc (HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam);
void PrintWindowColor(HWND hWnd, COLORREF nColor);
// Create the DTP... hDTP =
// Subclassing
OldDTPProc = SetWindowLong(hDTP GWL_WNDPROC,(LONG) (WNDPROC)
NewDTPProc);
LRESULT CALLBACK NewDTPProc (HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
static HBRUSH hBrushBkgnd;
static COLORREF nColor = RGB(255, 0,0);
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
PrintWindowColor(hWnd, nColor);
EndPaint(hWnd, &ps);
return 0;
}
break;
// For Edit control in Time Format
case WM_CTLCOLOREDIT:
{
if ( !hBrushBkgnd )
hBrushBkgnd = CreateSolidBrush(nColor);
SetBkColor((HDC)wParam, nColor);
return((LRESULT)hBrushBkgnd);
}
break;
}
return(CallWindowProc((WNDPROC)OldDTPProc, hWnd, uMsg, wParam,
lParam));
}
// To change background color before WM_PRINT
void PrintWindowColor(HWND hWnd, COLORREF nColor)
{
RECT rect;
GetWindowRect(hWnd, &rect);
MapWindowPoints(NULL, hWnd, (LPPOINT)&rect, 2);
long nWidth = rect.right - rect.left, nHeight = rect.bottom -
rect.top;
HDC hDC = GetDC(hWnd);
HDC hDCMem = CreateCompatibleDC(hDC);
HBITMAP hBitmap = CreateBitmap(nWidth, nHeight, GetDeviceCaps(hDC,
PLANES), GetDeviceCaps(hDC, BITSPIXEL), (const void *) NULL);
if (hBitmap)
{
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hDCMem, hBitmap);
HBRUSH hBrush = CreateSolidBrush(nColor);
if (hBrush)
{
HBRUSH hBrushOld = (HBRUSH)SelectObject(hDCMem, hBrush);
RECT rectFill = {0, 0, nWidth, nHeight};
FillRect(hDCMem, &rectFill, hBrush);
SelectObject(hDCMem, hBrushOld);
DeleteObject(hBrush);
}
SendMessage(hWnd, WM_PRINT, (WPARAM)hDCMem, PRF_CLIENT |
PRF_CHILDREN | PRF_NONCLIENT);
BitBlt(hDC, rect.left, rect.top, nWidth, nHeight, hDCMem, 0, 0,
SRCCOPY);
SelectObject(hDCMem, hBitmapOld);
DeleteObject(hBitmap);
}
DeleteDC(hDCMem);
ReleaseDC(hWnd, hDC);
}