-
BITMAPS in WM_PAINT
I am trying to remake minesweeper (with some tweaks). I got to as far as placing all the images on the window, but in minesweeper when you click down anywhere the smily faces changes. I am working on that right now in my program. This is what I have so far...
Code:
...
WM_LBUTTONDOWN:
bClick = true;
break;
WM_LBUTTONUP:
bClick = false;
break;
WM_PAINT:
...
if (!bClick)
SelectObject(hdc, LoadImage(NULL, "C:\\Program Files\\Minesweeper7\\Skins\\Default\\Idle.bmp", IMAGE_BITMAP, 26, 26, LR_LOADFROMFILE));
else
SelectObject(hdc, LoadImage(NULL, "C:\\Program Files\\Minesweeper7\\Skins\\Default\\Active.bmp", IMAGE_BITMAP, 26, 26, LR_LOADFROMFILE));
BitBlt(hdc, rWindowRect.right / 2 - 12, 12, 26, 26 , hdcmem, 0, 0, SRCCOPY);
...
http://i130.photobucket.com/albums/p...ntitled-44.jpg
It either draws one bitmap or the other. It would not switch between the bitmaps. Anyway around it?
I probably won't visit this page for a few days and I'm afraid I won't be able to find it after I come back, so please email me at [email protected] if you have a solution.
-
Assuming the rest of your drawing and DC creation is correct, assuming you used a variable with enough scope (static or global), ignoring the probable GDI leaks and that the drawing code should not be in the WM_PAINT handler, the issue appears to be that you are selecting the image into the wrong DC.
You need to SelectObject() the image into the memDC (not into the paint DC) and then BitBlt the image from the memDC to the right spot on the paint DC.