Thread: Problem with loading a bitmap

  1. #1
    Registered User
    Join Date
    Mar 2002

    Problem with loading a bitmap

    Im getting the following error when using the code below

    code: HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall);
    error: 'initializing' : cannot convert from 'void *' to 'struct HBITMAP__ *'
    Conversion from 'void*' to pointer to non-'void' requires an explicit cast

    I'm trying to load a bitmap and I am following first gdi tutorial on Can someone please tell me why I'm getting this error and how to fix it or where I can find another tutorial on the gdi?

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Off the top of my head, I'd tell you to try the crazy idea of:

    HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, g_hbmBall);

    Considering SelectObject doesn't just get used with bitmaps, I'd say it'd be a good idea

  3. #3
    Registered User
    Join Date
    Mar 2002
    OK, forget about the first message but can someone tell me why my image won't showup?

    Heres some of the code that goes inside the message loop. the banner variable is a HBITMAP and it is a global.

    case WM_CREATE:
    banner = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP2));
    if(banner == NULL)
    MessageBox(hwnd, "Could not load the Banner!", "Error", MB_OK | MB_ICONEXCLAMATION);

    case WM_PAINT:
    HDC hdc = BeginPaint(hwnd, &ps);
    HDC hdcMem = CreateCompatibleDC(hdc);
    SelectObject(hdcMem, banner);
    BitBlt(hdc, 7, 206, 468, 60, hdcMem, 0, 0, SRCCOPY);
    EndPaint(hwnd, &ps);

    case WM_DESTROY:

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 AM
  2. 32 bit color depth bitmap problem with XP
    By kalabala in forum C++ Programming
    Replies: 0
    Last Post: 12-22-2008, 06:56 AM
  3. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  4. Loading Bitmap under VC++
    By abu in forum Windows Programming
    Replies: 1
    Last Post: 05-14-2004, 01:07 AM
  5. Problem With My Bitmap
    By Sebastiani in forum Windows Programming
    Replies: 9
    Last Post: 10-29-2001, 09:54 PM