Hi. I'm having some problems making a listview (in report view) double-buffered. The code I have works fine (if you overlook the fact that it's allocating everything each time WM_PAINT is called,) but I can't seem to figure out how to draw the column headers. I'm assuming they're not actually part of the client area, but I've also tried various things involving WM_PRINTing PRF_NONCLIENT and similiar without much luck.
I'd really appreciate any hints!
The following is the code I currently have to paint the client area:
Code:
LRESULT CALLBACK LvPaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_PAINT:
{
HDC hdc, hdcNew;
HBITMAP hbm, hbmOld;
HBRUSH hbr;
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
hdcNew = CreateCompatibleDC(hdc);
hbm = CreateCompatibleBitmap(hdc, ps.rcPaint.right, ps.rcPaint.bottom);
hbmOld = SelectObject(hdcNew, hbm);
hbr = CreateSolidBrush(GetBkColor(hdc));
FillRect(hdcNew, &ps.rcPaint, hbr);
SendMessage(hWnd, WM_PRINTCLIENT, (WPARAM)hdcNew, (LPARAM)PRF_CLIENT|PRF_CHILDREN);
BitBlt(hdc, 0, 0, ps.rcPaint.right, ps.rcPaint.bottom, hdcNew, 0, 0, SRCCOPY);
SelectObject(hdcNew, hbmOld);
DeleteObject(hbm);
DeleteObject(hbr);
DeleteDC(hdcNew);
EndPaint(hWnd, &ps);
return TRUE;
}
case WM_ERASEBKGND:
return TRUE;
}
return CallWindowProc((WNDPROC)GetWindowLong(hWnd, GWL_USERDATA), hWnd, uMsg, wParam, lParam);
}