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
|
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HBITMAP hbBitMap = NULL;
switch (msg)
{
case WM_CREATE:
hbBitMap = LoadBitmap (GetModuleHandle (NULL),
MAKEINTRESOURCE (BITMAP_PICTURE));
if (hbBitMap == NULL)
{
MessageBox (hwnd,
"Bitmap failed to load",
NULL,
MB_OK | MB_ICONWARNING);
DestroyWindow (hwnd);
}
break;
case WM_PAINT:
{
BITMAP bm;
PAINTSTRUCT ps;
HDC hdc = BeginPaint (hwnd, &ps);
HDC hdcMem = CreateCompatibleDC (hdc);
HBITMAP hbmOld = (HBITMAP) SelectObject (hdcMem, hbBitMap);
GetObject (hbBitMap, sizeof (bm), &bm);
BitBlt (hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
SelectObject (hdcMem, hbmOld);
DeleteDC (hdcMem);
EndPaint (hwnd, &ps);
}
break;
}
return DefWindowProc (hwnd, msg, wParam, lParam);
}
|