Thread: LoadBitmap failing

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    2

    LoadBitmap failing

    Can anyone figure out why LoadBitmap would fail (resource not found)

    My resource has:
    501 BITMAP "test.bmp"

    my source has:

    LoadBitmap(hInstance, MAKEINTRESOURCE(501));

    Ideas?
    (dev-c++)

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    This poster has a similar problem.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    10
    Hellow;

    Follow examples, load image inside the static control, radio button, button.

    Code:
    /*
      Function created for Alejandro Ramirez Bastias
      Talca, Chile
    */
    LRESULT imgbmp(HWND hwnd, int bitmap)
    {
    SendMessage
        (
          hwnd,STM_SETIMAGE,IMAGE_BITMAP,
          (LPARAM)LoadImage
          (
            GetModuleHandle(NULL),MAKEINTRESOURCE(bitmap),IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR
          )
        );
    }
    Using:

    Code:
    :
    static HWND hImagen;
    hImagen = GetDlgItem(hwnd,IDC_IMAGE);
    :
    case WM_INITDIALOG:
        imgbmp(hImagen, 501);
        break;
    hwnd, this handle the control, for example; static WS_BITMAP.

    Bye
    Last edited by nostromos; 10-08-2005 at 11:22 PM.

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    207
    And *this* poster came up with a really good solution:

    Quote Originally Posted by Dante Shamest
    I think LoadImage can load bitmap resources that have 256 colors.

    Code:
    bitmap = (HBITMAP)LoadImage(GetModuleHandle(0),
                                MAKEINTRESOURCE(ID_MYBITMAP),
                                IMAGE_BITMAP,
                                0,0,0);
    BTW: Thanks Dante!

    mw
    Last edited by Lionmane; 10-09-2005 at 12:55 AM.
    Blucast Corporation

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    207
    I'm trying to use StretchBlt to make my bitmap cover the entire client area.

    How do I find the length/width of my bitmap?

    mw
    Blucast Corporation

  6. #6
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    How do I find the length/width of my bitmap?
    Before stretching?

    Try something like

    Code:
      if ( !hbitmap ) return 0 ;
      BITMAP bm ;
      GetObject(hbitmap,sizeof(BITMAP),&bm) ;
      int width = bm.bmWidth ;
      int height = bm.bmHeight ;

  7. #7
    Registered User
    Join Date
    Oct 2005
    Posts
    2
    Shame that it's not failing because it's got too many colours then, It's failing because it can't find it, error 1812 to be exact.

  8. #8
    Registered User
    Join Date
    May 2005
    Posts
    207
    Have you added the bitmap as a resource?

    I see you've added a reference of it to your resource file, but have you added the actual bitmap?

    mw
    Blucast Corporation

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 09-23-2008, 03:32 AM
  2. LoadBitmap Function
    By ejohns85 in forum Windows Programming
    Replies: 3
    Last Post: 08-27-2006, 06:19 AM
  3. CreateDevice failing
    By MadCow257 in forum Game Programming
    Replies: 6
    Last Post: 03-14-2006, 09:03 PM
  4. initializes all components of failing to false
    By romeoz in forum C++ Programming
    Replies: 21
    Last Post: 08-01-2003, 09:30 PM
  5. Super-Newbie. Need to see how to use LoadBitmap() correctly?
    By Sebastiani in forum Windows Programming
    Replies: 9
    Last Post: 09-07-2001, 01:28 PM