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. SetBitmap Problem

SetBitmap Problem

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelptutorialquestion
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.
  • E Offline
    E Offline
    Eric Vonjacson
    wrote on last edited by
    #1

    Hi All, I use a CStatic to show a bitmap in a dialog. The bitmap is a thumbnail of a file. Everytime when a file is chosen, the code call CStattic::SetBitmap to associates a new bitmap with the static control and the bitmap will be shown out immediately. But I minimize the dialog and maximize the dialog again, the bitmap in the CStatic control can't be shown out. Do you know how to show the picture out again when the dialog is maximized? thanks, Eric

    C Steve EcholsS 2 Replies Last reply
    0
    • E Eric Vonjacson

      Hi All, I use a CStatic to show a bitmap in a dialog. The bitmap is a thumbnail of a file. Everytime when a file is chosen, the code call CStattic::SetBitmap to associates a new bitmap with the static control and the bitmap will be shown out immediately. But I minimize the dialog and maximize the dialog again, the bitmap in the CStatic control can't be shown out. Do you know how to show the picture out again when the dialog is maximized? thanks, Eric

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Sounds like you've got a problem with the control not repainting itself.  What if you call Invalidate() on the CStatic when your form is shown ? ( NOte : this should have happened by itself )

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      1 Reply Last reply
      0
      • E Eric Vonjacson

        Hi All, I use a CStatic to show a bitmap in a dialog. The bitmap is a thumbnail of a file. Everytime when a file is chosen, the code call CStattic::SetBitmap to associates a new bitmap with the static control and the bitmap will be shown out immediately. But I minimize the dialog and maximize the dialog again, the bitmap in the CStatic control can't be shown out. Do you know how to show the picture out again when the dialog is maximized? thanks, Eric

        Steve EcholsS Offline
        Steve EcholsS Offline
        Steve Echols
        wrote on last edited by
        #3

        Is the bitmap getting deleted after you set it? If you're using CBitmap, and it goes out of scope, it will delete the gdi object.


        - S 50 cups of coffee and you know it's on!

        • S
          50 cups of coffee and you know it's on!
          Code, follow, or get out of the way.
        E 1 Reply Last reply
        0
        • Steve EcholsS Steve Echols

          Is the bitmap getting deleted after you set it? If you're using CBitmap, and it goes out of scope, it will delete the gdi object.


          - S 50 cups of coffee and you know it's on!

          E Offline
          E Offline
          Eric Vonjacson
          wrote on last edited by
          #4

          The code is like this:

          {
          CBitmap tempBitmap;
          ...
          HBITMAP hBitmap = HBITMAP(tempBitmap);
          m_picHolder.SetBitmap(hBitmap);
          ...
          }

          When call SetBitmap again, the bitmap can be shown out. But it will disappear after minimize and maximize the dialog. Thanks, Eric

          P Steve EcholsS 2 Replies Last reply
          0
          • E Eric Vonjacson

            The code is like this:

            {
            CBitmap tempBitmap;
            ...
            HBITMAP hBitmap = HBITMAP(tempBitmap);
            m_picHolder.SetBitmap(hBitmap);
            ...
            }

            When call SetBitmap again, the bitmap can be shown out. But it will disappear after minimize and maximize the dialog. Thanks, Eric

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #5

            Eric Vonjacson wrote:

            CBitmap tempBitmap;

            You need to create on heap , using new. Or , make CBitmap object, as member variable along with m_picHolder.

            Prasad Notifier using ATL | Operator new[],delete[][^]

            1 Reply Last reply
            0
            • E Eric Vonjacson

              The code is like this:

              {
              CBitmap tempBitmap;
              ...
              HBITMAP hBitmap = HBITMAP(tempBitmap);
              m_picHolder.SetBitmap(hBitmap);
              ...
              }

              When call SetBitmap again, the bitmap can be shown out. But it will disappear after minimize and maximize the dialog. Thanks, Eric

              Steve EcholsS Offline
              Steve EcholsS Offline
              Steve Echols
              wrote on last edited by
              #6

              I think tempBitmap is deleted when it goes out of scope, which also deletes the gdi resource it's wrapping. Try adding a CBitmap member variable to your class like: CBitmap m_bitmap; then in your function: { m_bitmap.LoadBitmap(); // or however you're getting it m_picHolder.SetBitmap(m_bitmap); }


              - S 50 cups of coffee and you know it's on!

              • S
                50 cups of coffee and you know it's on!
                Code, follow, or get out of the way.
              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