So sollte es jetzt aber funktionieren. Das Laden des Bitmaps musst du schon in der WinMain erledigen, weil du dazu das Instance-Handle benötigst.
Gruß
MCoder
C++:
...
HBITMAP hBitMap = NULL;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow)
{
...
hBitMap = (HBITMAP)LoadImage( hInstance,
MAKEINTRESOURCE(ID_BITMAP_MA),
IMAGE_BITMAP,
0,
0,
LR_DEFAULTSIZE | LR_CREATEDIBSECTION );
...
}
LRESULT APIENTRY WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
...
switch (message)
{
case WM_PAINT:
if( hBitMap )
{
PAINTSTRUCT ps
HDC hdc = BeginPaint(hwnd, &ps);
BITMAP bm;
GetObject(hBitMap, sizeof(BITMAP), &bm);
HDC hMemDC = CreateCompatibleDC(hdc);
HBITMAP hbmOld = (HBITMAP)SelectObject(hMemDC, hBitMap);
BitBlt( hdc,
0
0
bm.bmWidth,
bm.bmHeight,
hMemDC,
0,
0,
SRCCOPY );
SelectObject(hMemDC, hbmOld);
DeleteObject(hMemDC);
EndPaint(hwnd, &ps);
return 0L;
}
break;
...
}
...
}
MCoder