Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
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 51 52 53 54 |
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HBITMAP hBitmap; static HDC hdcBmp; static BITMAP bitmap; HDC hdc; PAINTSTRUCT ps; // Nachrichten switchen //------------------- switch(message) { case WM_CREATE: { hBitmap = (HBITMAP)LoadImageW(NULL,L"test.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); if(hBitmap == NULL) { MessageBoxW(hwnd,L"Bild konnte nicht geladen werden",L"Error",0); return -1; } GetObject (hBitmap, sizeof (BITMAP), &bitmap) ; return 0; } case WM_PAINT: { hdc = BeginPaint(hwnd, &ps); hdcBmp = CreateCompatibleDC(hdc); SelectObject(hdcBmp, hBitmap); BitBlt(hdc, 200, 200, bitmap.bmWidth, bitmap.bmHeight, hdcBmp, 0, 0, SRCCOPY) ; EndPaint(hwnd, &ps); return 0; } case WM_DESTROY: { // Anfrage zum Beenden senden //--------------------------- PostQuitMessage(0); return 0; } } // Den Rest der Standardwindowprozedur überlassen //----------------------------------------------- return DefWindowProc(hwnd, message, wParam, lParam); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
case WM_PAINT: { HDC hDC = BeginPaint(hWnd, &ps); HDC hMemDC = CreateCompatibleDC(hDC); HBITMAP hBitmapOld = static_cast<HBITMAP>(SelectObject(hMemDC, hBitmap)); BitBlt(hDC, 200, 200, bitmap.bmWidth, bitmap.bmHeight, hMemDC, 0, 0, SRCCOPY) ; EndPaint(hWnd, &ps); SelectObject(hMemDC, hBitmapOld); DeleteDC(hMemDC); return 0; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
if(hBitmap[i] == NULL) { MessageBoxW(hwnd,L"Bild konnte nicht geladen werden",L"Error",0); DWORD dw = GetLastError(); wchar_t temp[512]; swprintf(temp, 512, L"Code: %d", dw); MessageBox(hwnd,temp,NULL,MB_OK); return -1; } |
Werbeanzeige