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. mfc LoadBitmap hangs my application...

mfc LoadBitmap hangs my application...

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++designhardwaredebugging
10 Posts 3 Posters 16 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.
  • C Offline
    C Offline
    charlieg
    wrote on last edited by
    #1

    VS2008, Windows Embedded Compact 7, mfc dialog application that is 4 years old. It's been working fine. Today I've been making improvements, tracking down some long standing issues. Up until this afternoon, I could pretty much debug where I wanted but then suddenly my UI loop stalled in the OnInitDialog. Stepping through, I came to a couple of LoadBitmap calls that I use to load images from the embedded resources. The first call does not error out, it just never comes back from the LoadBitmap call. This smells like some weird elephanting debris from VS2008. Some references suggest memory issues on the target device, etc, but it's been rebooted, this is a lightweight app... and doesn't use much memory. Anyone seen LoadBitmap stall like this?

    Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

    _ 1 Reply Last reply
    0
    • C charlieg

      VS2008, Windows Embedded Compact 7, mfc dialog application that is 4 years old. It's been working fine. Today I've been making improvements, tracking down some long standing issues. Up until this afternoon, I could pretty much debug where I wanted but then suddenly my UI loop stalled in the OnInitDialog. Stepping through, I came to a couple of LoadBitmap calls that I use to load images from the embedded resources. The first call does not error out, it just never comes back from the LoadBitmap call. This smells like some weird elephanting debris from VS2008. Some references suggest memory issues on the target device, etc, but it's been rebooted, this is a lightweight app... and doesn't use much memory. Anyone seen LoadBitmap stall like this?

      Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

      _ Offline
      _ Offline
      _Flaviu
      wrote on last edited by
      #2

      Did you tried to load another bitmap, something small in order to find out where is the problem ?

      C 1 Reply Last reply
      0
      • _ _Flaviu

        Did you tried to load another bitmap, something small in order to find out where is the problem ?

        C Offline
        C Offline
        charlieg
        wrote on last edited by
        #3

        I actually did... there are only three bitmaps in the project. I added some code:

        CBitmap myBitmap;
        myBitmap.LoadBitmap(IDB_STOP);

        it never returns from the LoadBitmap... very odd. The bitmaps are not large (200x200?), and the really weird part, again, is that this code has been working for many years.

        Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

        _ L 2 Replies Last reply
        0
        • C charlieg

          I actually did... there are only three bitmaps in the project. I added some code:

          CBitmap myBitmap;
          myBitmap.LoadBitmap(IDB_STOP);

          it never returns from the LoadBitmap... very odd. The bitmaps are not large (200x200?), and the really weird part, again, is that this code has been working for many years.

          Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

          _ Offline
          _ Offline
          _Flaviu
          wrote on last edited by
          #4

          I would try a little workaround: use CImage instead of CBitmap ... at least you will know where is the problem, or, you will solve the issue .... However, CBitmap is reliable ... I don't think that code from above is causing the problem ... the cause must be in else where.

          1 Reply Last reply
          0
          • C charlieg

            I actually did... there are only three bitmaps in the project. I added some code:

            CBitmap myBitmap;
            myBitmap.LoadBitmap(IDB_STOP);

            it never returns from the LoadBitmap... very odd. The bitmaps are not large (200x200?), and the really weird part, again, is that this code has been working for many years.

            Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

            L Offline
            L Offline
            leon de boer
            wrote on last edited by
            #5

            Check you have not got a clash on IDB_STOP and you actually have the resource of that ID in the project. All you need is a corrupt resource file and it can't connect the dots.

            In vino veritas

            _ C 2 Replies Last reply
            0
            • L leon de boer

              Check you have not got a clash on IDB_STOP and you actually have the resource of that ID in the project. All you need is a corrupt resource file and it can't connect the dots.

              In vino veritas

              _ Offline
              _ Offline
              _Flaviu
              wrote on last edited by
              #6

              That's why I told him to try to load another bitmap resource :) just for testing ...

              1 Reply Last reply
              0
              • L leon de boer

                Check you have not got a clash on IDB_STOP and you actually have the resource of that ID in the project. All you need is a corrupt resource file and it can't connect the dots.

                In vino veritas

                C Offline
                C Offline
                charlieg
                wrote on last edited by
                #7

                good idea, "use the source luke"... looking now - yeah, this looks good. I would expect the loadbitmap operation would just fail and not hang. The resource is built into the exe. Trying the load image... I love you Microsoft.

                Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                C 1 Reply Last reply
                0
                • C charlieg

                  good idea, "use the source luke"... looking now - yeah, this looks good. I would expect the loadbitmap operation would just fail and not hang. The resource is built into the exe. Trying the load image... I love you Microsoft.

                  Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                  C Offline
                  C Offline
                  charlieg
                  wrote on last edited by
                  #8

                  So, tried the CImage -> LoadImage approach - no go. Hangs in that call as well. I'm going to sell my house and buy a sailboat.... elephanting code - okay, I figured out why the call hangs. This application is my application loader code in an embedded target. We have two types of upgrades - one with and one without an operating system. So, one thing I need to do is dismount and remount the device partitions (this is Windows Embedded Compact 7), so I can modify OS files. This typically is not a concern, since by the time we're running, everything is running out of ram. Once complete, the device reboots. No harm. Now I don't know how LoadBitmap is implemented, but it appears that it reads the resource information from the exe file and not what is in RAM. Egg on my face since I missed the #define change. I still argue that LoadBitmap should return gracefully with an error code. Heh it's mfc, filed under "don't do that." Appreciate all the suggestions.

                  Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                  L 1 Reply Last reply
                  0
                  • C charlieg

                    So, tried the CImage -> LoadImage approach - no go. Hangs in that call as well. I'm going to sell my house and buy a sailboat.... elephanting code - okay, I figured out why the call hangs. This application is my application loader code in an embedded target. We have two types of upgrades - one with and one without an operating system. So, one thing I need to do is dismount and remount the device partitions (this is Windows Embedded Compact 7), so I can modify OS files. This typically is not a concern, since by the time we're running, everything is running out of ram. Once complete, the device reboots. No harm. Now I don't know how LoadBitmap is implemented, but it appears that it reads the resource information from the exe file and not what is in RAM. Egg on my face since I missed the #define change. I still argue that LoadBitmap should return gracefully with an error code. Heh it's mfc, filed under "don't do that." Appreciate all the suggestions.

                    Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                    L Offline
                    L Offline
                    leon de boer
                    wrote on last edited by
                    #9

                    I agree LoadBitmap should not fail like that but it is specified the resources are never lifted into RAM. They are tagged in special sections in the file and are excluded from the normal executable load to avoid using memory when not required. Remember a file may contain many resources for different resolutions, languages and the like and much would then be redundant duplicates hogging memory.

                    In vino veritas

                    C 1 Reply Last reply
                    0
                    • L leon de boer

                      I agree LoadBitmap should not fail like that but it is specified the resources are never lifted into RAM. They are tagged in special sections in the file and are excluded from the normal executable load to avoid using memory when not required. Remember a file may contain many resources for different resolutions, languages and the like and much would then be redundant duplicates hogging memory.

                      In vino veritas

                      C Offline
                      C Offline
                      charlieg
                      wrote on last edited by
                      #10

                      :thumbsup:

                      Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                      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