FREEDOM! Win Bitmap Unload

This is a discussion on FREEDOM! Win Bitmap Unload within the Windows Programming forums, part of the Platform Specific Boards category; I got a bitmap problem. I used the Bitblt() to display bitmap, everything seems to work fine. However, using sysmon ...

  1. #1
    _Unregistered_
    Guest

    Angry FREEDOM! Win Bitmap Unload

    I got a bitmap problem.
    I used the Bitblt() to display bitmap, everything seems to work fine. However, using sysmon and other programs, I notice the handles were never free. Memory were draining from it. Windows will eventally come to a ugly death.
    I'm using BCW 4.02, compile a C only (no OOB) code, for Win3.X program. I got similar code compiled by some book author, and same problem occur. The bitmap loading/display, and unloading code is found in the sample (bwinapi.hlp). Should I used other functions (is there any)? Is this my problem? Window can't manage to free memory, it's a simple task. I tried it under some WM_COMMAND section, also in WM_PAINT: section (yes, I used BeginPaint() and EndPaint(). I just can't figure out why.

    please help
    thanks.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use DeleteObject on all gdi object handles when you are done with them. If you initialise a gdi object, such as a bitmap within a function then you should use DeleteObject on the bitmap handle within that function. If you initialise the gdi object once at program start eg within WM_CREATE handler then use DeleteObject when you exit the program eg WM_DESTROY handler.

    I think the older the os then the less gdi resources are available to begin with in which case you should load your bitmap, blt it and then free the associated resources with DeleteObject.

    Hope that's of some use to you.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    If the objects are in your callback ensure they are declared as static.

    If you SelectObject() catch the returned object. Replace this 'stock' GDI resource with SelectObject() just before you delete the created GDI resource.

    In other words ensure the HDC is exactly as you found it before release or deleting it.
    "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

  4. #4
    _Unregistered_
    Guest
    thank you all, I'll try that.

  5. #5
    _Unregistered_
    Guest

    DIE! diag

    I tried that, it works w/ Windows-based app, but fail to display in a Dialog-based app (I load the bitmap under WM_INITDIAG: section). I knew the handle loaded, but can't display. SelectObject() fails to load hbitmap into holdbitmap for display.

    so all I can see is a white screen unless I load it every time in WM_PAINT:.

    any ideas to wake me up?

  6. #6
    Unregistered
    Guest
    Sounds like your are loosing the handle to the bitmap.

    Create a HDC to hold the bitmap and select into it the bitmap.
    Draw this to the screen each time a WM_PAINT is called.
    Release the resources and delete the DC at WM_CLOSE.

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Opps forgot to log in
    "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

  8. #8
    _Unregistered_
    Guest

    Question

    I used BeginPaint for the hDC, and free it (ReleaseDC) in the splash screen. then load it again, and wouldn't work in main dialog box...

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. Win 32 Game Bitmap issue
    By loopshot in forum Game Programming
    Replies: 5
    Last Post: 03-02-2005, 11:55 AM
  3. help with this
    By tyrantil in forum C Programming
    Replies: 18
    Last Post: 01-30-2005, 03:53 PM
  4. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  5. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 09:07 AM

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