Thanks. That is more like it:
Example:
Code:
case WM_PAINT:
HDC hdcMemory;
HDC hdc;
BITMAP bm;
PAINTSTRUCT ps;
hdcMemory = CreateCompatibleDC(hdc);
hdc = BeginPaint(hwnd, &ps);
int i;
int x_coord, y_coord;
for(i=0; i<(TILE_NUM*TILE_NUM); i++)
{
if( GameLogic.game_board[i] == 1 )
{
ShowWindow(ButtonHandles.hButton[i], SW_HIDE);
x_coord == TILE_SIZE*(i%TILE_NUM);
y_coord == (int)(i/TILE_NUM);
SelectObject(hdcMemory, hbmCross);
BitBlt(hdc, x_coord, y_coord, TILE_SIZE, TILE_SIZE, hdcMemory, 0, 0, SRCCOPY);
}
else if( GameLogic.game_board[i] == -1 )
{
ShowWindow(ButtonHandles.hButton[i], SW_HIDE);
x_coord == TILE_SIZE*(i%TILE_NUM);
y_coord == (int)(i/TILE_NUM);
SelectObject(hdcMemory, hbmNaught);
BitBlt(hdc, x_coord, y_coord, TILE_SIZE, TILE_SIZE, hdcMemory, 0, 0, SRCCOPY);
}
}
EndPaint(hwnd, &ps);
DeleteDC(hdcMemory);
//DeleteDC(hdc); This is a no no.
Ok, now that fixes some of the problem. But when are you actually drawing anything to the hdcMemory buffer? By the way, you should only make the hdcMemory buffer whenever the window is resizes, in my opinion. But just leave it alone for now. It is just an issue of slowing down drawing. But since your drawing still doesn't technically work, optimizing it is a moot point.