Hi guys I am using Bloodshed Dev C++ 4 having real trouble with the LoadBitmap() function. I have been to the thread titled:
C Board - Super-Newbie. Need to see how to use LoadBitmap() correctly?
And consequently I have tried the following:
1.
This one didn’t compile giving a parse error on the lines beginning with HINSTANCE and hbmrocket.
Source Code:
resource file:Code:HBITMAP hbmrocket; switch(msg) { case WM_CREATE: { HINSTANCE hInstance = GetWindowLong(hwnd, GWL_HINSTANCE); hbmrocket = LoadBitmap(hInstance, "myBitmap"); } break; //rest of code
myBitmap BITMAP "C:/Games/civ2-tot/civ/Original/23imp.bmp"
2.
This one compiles but does not paint the bitmap or show the message box.
Source code:
resource file:Code:HBITMAP hbmrocket = NULL; switch(msg) { case WM_CREATE: { hbmrocket = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_ROCKET)); if(hbmrocket == NULL) MessageBox(hwnd, "Could not load myBitmap!", "Error", MB_OK | MB_ICONEXCLAMATION); }
IDD_ROCKET BITMAP "C:/Games/civ2-tot/civ/Original/65imp.bmp"
myBitmap BITMAP "C:/Games/civ2-tot/civ/Original/65imp.bmp"
and IDD_ROCKET is #defined correctly in a header file (it compiles so no error there).
In both cases, my WM_PAINT case is as follows:
Is anyone able to see what the problem is and give an answer? If so I would be most grateful.Code:case WM_PAINT: { BITMAP bm; PAINTSTRUCT ps; HBITMAP hbmOld; HDC hdc = BeginPaint(hwnd, &ps); HDC hdcMem = CreateCompatibleDC(hdc); SelectObject(hdcMem, hbmrocket); GetObject(hbmrocket, sizeof(bm), &bm); BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); EndPaint(hwnd, &ps); } break;



LinkBack URL
About LinkBacks


