1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
void DrawBitmapT(HWND hwnd, HDC hdc, int x, int y, HBITMAP hBit, COLORREF crTransparent)
{
    HDC MemDC, BackDC;
    HBITMAP OldBitmap, BackBitmap;
    int bx, by;
    BITMAP bit;
    RECT rect;
 
    GetClientRect(hwnd, &rect);
    
    MemDC = CreateCompatibleDC(hdc);
    BackBitmap = CreateCompatibleBitmap(hdc, rect.right, rect.bottom);
    
    OldBitmap = (HBITMAP)SelectObject(MemDC, BackBitmap);
    BackDC = CreateCompatibleDC(hdc);
    SelectObject(BackDC, hBit);
    
 
 
    GetObject(hBit, sizeof(BITMAP), &bit);
    bx = bit.bmWidth;
    by = bit.bmHeight;
 
    //TransparentBlt(MemDC, x, y, bx, by, BackDC, 0, 0, bx, by, crTransparent);
    BitBlt(MemDC, x, y, bx, by, BackDC, 00, SRCCOPY);
 
    DeleteDC(BackDC);
 
    //TransparentBlt(hdc, 0, 0, rect.right, rect.bottom, MemDC, 0, 0, 0, 0, crTransparent);
    BitBlt(hdc, 00, rect.right, rect.bottom, MemDC, 00, SRCCOPY);
 
 
    DeleteObject(SelectObject(MemDC, OldBitmap));
    DeleteDC(MemDC);
    DeleteObject(BackBitmap);
 
}
 
case WM_MOUSEMOVE:
    xpos = (int)LOWORD(lParam);
    ypos = (int)HIWORD(lParam);
    InvalidateRect(g_hWnd, 0, FALSE);
    break;
 
case WM_PAINT:
        hdc = BeginPaint(g_hWnd, &ps);
        DrawBitmapT(g_hWnd, hdc, xpos, ypos, hBitmap, RGB(255255255));
        EndPaint(g_hWnd, &ps);
        return 0;
cs


간단한 게임을 만들고 있습니다

졸라맨을 띄워주고 마우스 움직일때마다 새로 그려주는데

깜빡임 없이 그릴려고 이런식으로 짠건데 의도대로 안되네요..

원래 회색 배경이어야 하는데 저렇게 검은색 배경으로 되고 마우스를 움직이면 졸라맨을 제외하고 저기 보이는 컨트롤들이 전부 깜빡입니다

어느 부분이 잘못된걸까요?
WINAPI 정복 책도 참고해봤고 네이버랑 구글에 api 더블버퍼링 검색해서 몇 페이지를 넘겨가며 다 찾아보면서 따라해봐도 안되네요

도움좀 부탁드려요!