Offscreen Drawing Problem
I am doing some offscreen drawing and then blitting it to the screen, but it doesn't seem to show up so I'm obviously doing something wrong or overlooking something.
What I am doing is more complex but I can't get even something this simple to work:
I also handle WM_ERASEBKGND
HDC hdc ;
BeginPaint ( hWnd, &ps ) ;
// quick fix *****
GetClientRect ( hWnd, &ps.rcPaint ) ;
// create a dc and a bitmap to work on
hdc = CreateCompatibleDC ( ps.hdc ) ;
hMem = CreateCompatibleBitmap ( ps.hdc, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top ) ;
SelectObject ( hdc, hMem ) ;
FillRect ( hdc, &ps.rcPaint, GetStockObject ( WHITE_BRUSH ) ) ;
// move it to our display
BitBlt ( ps.hdc, 0, 0,
ps.rcPaint.right - ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top,
hdc, 0, 0, SRCCOPY ) ;
DeleteDC ( hdc ) ;
EndPaint ( hWnd, &ps ) ;
The background of the window is still 'transparent' after this runs. Looking at it with a debugger all my handles are non-zero so I'm really stuck with this.
return ( 1 ) ;
I'm basically trying to use an 'oldschool' back buffer to avoid that annoying flickering.
I'm rather new to the windows gdi so it could be something really simple, help is greatly appreciated.