LoadBitmap with variable bitmap name

This is a discussion on LoadBitmap with variable bitmap name within the Windows Programming forums, part of the Platform Specific Boards category; Hey, I think this is a first, Im not having problems troubleshooting :-). I got everything working for the most ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    202

    LoadBitmap with variable bitmap name

    Hey,
    I think this is a first, Im not having problems troubleshooting :-). I got everything working for the most part. I even got the bitmap loading correctly. The problem being that the bitmap in the one section has to change on each WM_Timer message(well with the correct LOWORD). The Resource name of the bitmap will be set in a seperate function. The problem being I need to call MAKEINTRESOURCE for the bitmap name. If I try that with the variable it tries finding the bitmap with the variable's name. How can I have a LoadBitmap call with a variable bitmap name??
    "Christ died for our sins. Dare we make his martyrdom meaningless by not committing them?"

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    char buff[100];
    sprintf( buff, "bitmap%d.bmp", num );
    LoadBitmap( instance, buff );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Ummm.......

    LoadBitmap() only loads bmp from the exe resources. It needs the MAKEINTRESOURCE()

    Use a switch or if/else. Change the index with the timer msg in the callback (ie increment the last value)

    I would load them all at start.
    Keep an array of handles and just use the correct index.
    Free all at close (after ensuring none are selected into a DC)



    or use LoadImage(). Can specify the full path to the image if use LR_LOADFROMFILE

    ie
    "c:\\SomeFolder\\MyBmp.bmp"

    or for folders off the working folder

    ".\\MyBmp.bmp"
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ResHacker error replacing bitmap file
    By 7stud in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2004, 07:54 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 05:04 PM
  3. Loading a Bitmap resource for OpenGL Texture[x]
    By the dead tree in forum Game Programming
    Replies: 4
    Last Post: 08-26-2004, 02:12 PM
  4. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  5. Super-Newbie. Need to see how to use LoadBitmap() correctly?
    By Sebastiani in forum Windows Programming
    Replies: 9
    Last Post: 09-07-2001, 02:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21