我不擅长winapi领域..所以我想请你帮忙。
以下是代码。
void DrawScreen(HDC hdc)
{
int x = 0;
int y = 0;
BITMAP bit;
HBITMAP backBitmap;
HBITMAP hOldBitmap;
HBITMAP hOldBitmap2;
HDC backMemDC, MemDc;
backBitmap = CreateCompatibleBitmap(hdc, rt.right, rt.bottom);
backMemDC = CreateCompatibleDC(hdc);
MemDc = CreateCompatibleDC(backMemDC);
//hOldBitmap2 = (HBITMAP)SelectObject(MemDc, backBmitmap2);
FillRect(backMemDC, &rt, (HBRUSH)GetStockObject(WHITE_BRUSH));
hOldBitmap = (HBITMAP)SelectObject(backMemDC, backBitmap);
for ( y = 0; y < 3; ++y)
{
for ( x = 0; x < 3; ++x)
{
switch (cChessBoard[y][x])
{
case '#':
iBit = WHITE_BOARD;
break;
case '@':
iBit = BLACK_BOARD;
break;
SelectObject(MemDc, hBit[iBit]);
}//end of switch
hOldBitmap2 = (HBITMAP)SelectObject(MemDc,hBit[iBit]);
BitBlt(backMemDC, x*BW, y*BH, BW, BH, MemDc, 0, 0, SRCCOPY);
}//end of for
}//end of for
hOldBitmap2 = (HBITMAP)SelectObject(MemDc, hBit[PLAYER]);
BitBlt(backMemDC, Player.m_iX*BW, Player.m_iY*BH, BW, BH, MemDc, 0, 0, SRCCOPY);
//InvalidateRect(hWndMain, NULL, FALSE);
BitBlt(hdc, 0, 0, rt.right, rt.bottom, backMemDC, 0, 0, SRCCOPY);
ReleaseDC(hWndMain,hdc);
DeleteObject(hOldBitmap);
DeleteDC(backMemDC);
DeleteDC(MemDc);
}
从上面的代码中可以看出,我想做双缓冲。
但我仍然无法停止闪烁......有人帮我吗?
转移到内存直流并将内容移动到hdc是不对的?