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
| LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; static HDC hMemDC; static HBITMAP hBitmap; static BITMAP bitmap;
switch(message) { case WM_CREATE : hdc = GetDC(hWnd); hMemDC = CreateCompatibleDC(hdc); hBitmap = LoadBitmap(hInst, "mybmp"); SelectObject(hMemDC, hBitmap); GetObject(hBitmap, sizeof(BITMAP), &bitmap); ReleaseDC(hWnd, hdc); break; case WM_PAINT : hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rect); BitBlt(hdc, bmx, bmy, bitmap.bmWidth, bitmap.bmHeight, hMemDC, 0, 0, SRCCOPY); EndPaint(hWnd, &ps); break; case WM_DESTROY : DeleteObject(hBitmap); ReleaseDC(hWnd, hMemDC); PostQuitMessage(0); break; } }
|