Thread: I'm having so much trouble with LoadImage()!!!

  1. #1
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002

    I'm having so much trouble with LoadImage()!!!

    I have had no end of trouble in displaying a bitmap. I would so appreciate it if someone could help, i have tried everything. I have attached a zip file containing my resource file rsrc.rc, my source file, bitmap.cpp and my header file resource1.h along with the bitmap i am trying to display. Currently the path to the bitmap in the .rc file is to the A: drive so you might want to change it and you might want to use a different bitmap. But basically i just can't get any bitmap to be displayed at all. If anyone could create themselves a project, copy my code in, build/compile it and see why it won't work i would be so grateful. I can get it to compile and it displays the "managed to load bitmap" message ok but then nothing is displayed.

    I am using bloodshed dev C++.


  2. #2
    Join Date
    Jan 2002
    Replace the line in your window procedure:

    HBITMAP hbmrocket = NULL;


    static HIBITMAP hbmrocket;

    Or keep the same line but make it global ie move it out of the window procedure.

    If you do not declare your variables as static when used in that way then each time the window procedure is called ( a lot ) the variable will be re-initialised.

    I haven't looked at the rest of your code nor have I compiled it but that looks like it will at least allow your bitmap handle to persist between calls.

    Good luck.

  3. #3
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002

    Thank You SOOOOOOO Much!!!!

    It worked!!!!!!!!! I can't thank you enough!!!! I had spent hours trying to figure out what was wrong!!!!

    Thanks again!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LoadImage()
    By Gordon in forum Windows Programming
    Replies: 15
    Last Post: 12-22-2007, 06:16 PM
  2. Replies: 6
    Last Post: 01-03-2007, 03:02 PM
  3. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 12:58 PM
  4. C++ program trouble
    By senrab in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2003, 11:55 PM
  5. LoadImage doesn't work when my program is accesing the hardrive
    By pinkcheese in forum Windows Programming
    Replies: 2
    Last Post: 04-20-2002, 12:39 AM