Thread: LoadBitmap with variable bitmap name

  1. #1
    Registered User
    Join Date
    Nov 2001

    LoadBitmap with variable bitmap name

    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
    The edge of the known universe
    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.

  3. #3
    train spotter
    Join Date
    Aug 2001
    near a computer

    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


    or for folders off the working folder

    "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, 04: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, 01: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, 01:28 PM