So here is the story: I am creating a tetris clone. And I have a a 2-d int array that holds the whole board in terms of a number 0-7, 0 for nothing there, and 1-7 cooresponding to the color of square. (each of the 7 tetris piece types has its own color).
Now I have a function called "RefreshBoard" that re outputs everything on the board from this array. Here is that function:
hbmSquare is a HBITMAP array that holds in each cell an HBITMAP object for each of the 7 colors. Everything else should be self-explanatory.
The problem I am having is something to do with this function, I am asking some of you experienced windows programmers to just look at this function and tell me if you see something innately wrong with it. The problem I have having is pretty much that BitBlt is in fact failing. The message box that goes off when it fails is poping up. I can't explain why this is, and so I will just ask you to tell me if you see something wrong with it, and I'll go from there. Here is this function:
Code:
void Board::RefreshBoard(Piece* currentPiece)
{
HDC hdcMemory2;
hdcMemory2 = CreateCompatibleDC(hdc);
HBITMAP hbmCurrentSq;
bool check;
for(int y=0; y<20; y++)
{
for(int x=0; x<10; x++)
{
if(theBoard[x][y] > 0) // if the square is not blank
{
hbmCurrentSq = hbmSquare[theBoard[x][y]-1];
SelectObject(hdcMemory2, hbmCurrentSq);
check = BitBlt(hdc, x*17, y*17, 17, 17, hdcMemory2, 0, 0, SRCCOPY);
if (!check)
{
HWND hwnd;
MessageBox(hwnd, "BitBlt Fails!", "C baby", MB_OK | MB_ICONEXCLAMATION);
}
}
else if(theBoard[x][y] == 0)
currentPiece->RemoveOnePiece(x,y);
}
}
DeleteDC(hdcMemory2);
}
I appreciate your help! Keep in mind, this isn't throwing any compiler errors, the error is in the workings of the function, not its syntax.
Nimit