Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Disappearing images

Disappearing images

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlounge
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Killen
    wrote on last edited by
    #1

    I have a really irritating problem. In my program, a user can browse images by clicking on two buttons (one going forward and one backwards). After a while the images are no longer displayed. The area is updated, but instead of displaying the image, the area is white. The shape is still visible though (and updated if I continue browsing) and it is correct. Also the image data to be displayed is correct, as I have seen when debugging the application. But there is no real image displayed to the user, only a white rectangle of the image. The buttons that I use are of a CButton-derrived class that I call ImageButton. At the same time as the image dissapears, the images dissapear from the buttons too! This occurs after browsing about 200 images, the exact amount is random. What could be the problem? I am thankful for all comments! /Killen

    I T B 3 Replies Last reply
    0
    • K Killen

      I have a really irritating problem. In my program, a user can browse images by clicking on two buttons (one going forward and one backwards). After a while the images are no longer displayed. The area is updated, but instead of displaying the image, the area is white. The shape is still visible though (and updated if I continue browsing) and it is correct. Also the image data to be displayed is correct, as I have seen when debugging the application. But there is no real image displayed to the user, only a white rectangle of the image. The buttons that I use are of a CButton-derrived class that I call ImageButton. At the same time as the image dissapears, the images dissapear from the buttons too! This occurs after browsing about 200 images, the exact amount is random. What could be the problem? I am thankful for all comments! /Killen

      I Offline
      I Offline
      Ivor S Sargoytchev
      wrote on last edited by
      #2

      Looks like your app leaks GDI resources. If you are using Windows 2000 or XP you can monitor the available GDI objects through the "Processes" tab of the Task Manager. Just add the "GDI Objects" column. In Windows 9x you have to right click on "My Computer" and open the properties. One of the tabs should have "System Resources". Run your app and look at the available GDI resources. Then load a few images and look again. Do not close your app. If the GDI resources decrease you have a GDI leak. To find the GDI leak use BoundsChecker or Purify. Or simply look through your code and make sure you release icons, images, etc. Also make sure you select all previous GDI objects back in case you are using CDC::SelectObject(). Ivor S. Sargoytchev Dundas Software

      K 1 Reply Last reply
      0
      • K Killen

        I have a really irritating problem. In my program, a user can browse images by clicking on two buttons (one going forward and one backwards). After a while the images are no longer displayed. The area is updated, but instead of displaying the image, the area is white. The shape is still visible though (and updated if I continue browsing) and it is correct. Also the image data to be displayed is correct, as I have seen when debugging the application. But there is no real image displayed to the user, only a white rectangle of the image. The buttons that I use are of a CButton-derrived class that I call ImageButton. At the same time as the image dissapears, the images dissapear from the buttons too! This occurs after browsing about 200 images, the exact amount is random. What could be the problem? I am thankful for all comments! /Killen

        T Offline
        T Offline
        Terry ONolley
        wrote on last edited by
        #3

        Sounds like you are running out of resources. Are you making sure you delete the images no longer showing?


        Have you answered an MTQ? Check out the stats!

        1 Reply Last reply
        0
        • I Ivor S Sargoytchev

          Looks like your app leaks GDI resources. If you are using Windows 2000 or XP you can monitor the available GDI objects through the "Processes" tab of the Task Manager. Just add the "GDI Objects" column. In Windows 9x you have to right click on "My Computer" and open the properties. One of the tabs should have "System Resources". Run your app and look at the available GDI resources. Then load a few images and look again. Do not close your app. If the GDI resources decrease you have a GDI leak. To find the GDI leak use BoundsChecker or Purify. Or simply look through your code and make sure you release icons, images, etc. Also make sure you select all previous GDI objects back in case you are using CDC::SelectObject(). Ivor S. Sargoytchev Dundas Software

          K Offline
          K Offline
          Killen
          wrote on last edited by
          #4

          Thanks! There was a GDI leak allright. The leak occurs in my drawing function for the ImageButton. Now I only need to figure out what is causing it. Do you know of any 'typical' pitfalls leading to this kind of leakage?

          1 Reply Last reply
          0
          • K Killen

            I have a really irritating problem. In my program, a user can browse images by clicking on two buttons (one going forward and one backwards). After a while the images are no longer displayed. The area is updated, but instead of displaying the image, the area is white. The shape is still visible though (and updated if I continue browsing) and it is correct. Also the image data to be displayed is correct, as I have seen when debugging the application. But there is no real image displayed to the user, only a white rectangle of the image. The buttons that I use are of a CButton-derrived class that I call ImageButton. At the same time as the image dissapears, the images dissapear from the buttons too! This occurs after browsing about 200 images, the exact amount is random. What could be the problem? I am thankful for all comments! /Killen

            B Offline
            B Offline
            bnn3nasdfasdfa
            wrote on last edited by
            #5

            Sounds like you might not be freeing them. If you are loading bitmaps, make sure to use the DeleteObject( HDIOBJECT ) before continuing on. If this doesn't work, try redrawing the object section with the images using the RedrawWindow( HWND, DWORD ) and see if this kicks it.

            K 1 Reply Last reply
            0
            • B bnn3nasdfasdfa

              Sounds like you might not be freeing them. If you are loading bitmaps, make sure to use the DeleteObject( HDIOBJECT ) before continuing on. If this doesn't work, try redrawing the object section with the images using the RedrawWindow( HWND, DWORD ) and see if this kicks it.

              K Offline
              K Offline
              Killen
              wrote on last edited by
              #6

              Yeah, it was a call to GetIconInfo which caused the bug. The received bitmaps were never deleted :| Thanks for all your assistance!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups