Ok, I have the following code in my window processes function (where you would expect it in the switch-case block):
And it does exactly what I expect it to, draw a big red rectangle in the window.Code:case WM_PAINT: { PAINTSTRUCT Ps; HDC hDC = BeginPaint(hwnd, &Ps); HBITMAP graph = CreateCompatibleBitmap(hDC, 400, 300); int x, y; SelectObject(hDC, graph); for( x = 0; x < 400; x++) for( y = 0; y < 300; y++) SetPixel(hDC, x, y, RGB(255, 0, 0)); EndPaint(hwnd, &Ps); break; }
However, if I do the following:
The rectangle I get is black. Can anybody tell me why this is?Code:case WM_PAINT: { PAINTSTRUCT Ps; HDC hDC = BeginPaint(hwnd, &Ps); HDC testbit = CreateCompatibleDC(hDC); HBITMAP graph = CreateCompatibleBitmap(testbit, 400, 300); int x, y; SelectObject(testbit, graph); for( x = 0; x < 400; x++) for( y = 0; y < 300; y++) SetPixel(testbit, x, y, RGB(255, 0, 0)); BitBlt(hDC,0,0,400,300,testbit,0,0,SRCCOPY); DeleteDC(testbit); EndPaint(hwnd, &Ps); break; }



LinkBack URL
About LinkBacks


