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. how to properly display buttons over an image

how to properly display buttons over an image

Scheduled Pinned Locked Moved C / C++ / MFC
graphicstutorialquestion
10 Posts 3 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.
  • G Offline
    G Offline
    genush
    wrote on last edited by
    #1

    I have a CFormView where I want to display an image and show some buttons over the image. I get the device context for the view, create a compatible bitmap, use the LPPICTURE Render(*) function to display the image file into the DC, then use BitBlt(*) of CDC to display the image. The buttons are placed onto the form. This kind of works, although if I display another window over the form, or move the cursor into the title bar or the system status bar, all the buttons disappear. I would like to place the buttons dynamically, and tried to use SetWindowPos(*) for one of the buttons. But when I called SetWindowPos(*) for that button, everything (image and other buttons) disappeared. Is there a proper way to display buttons over an image so they don't disappear, and also to do so dynamically?

    F E 2 Replies Last reply
    0
    • G genush

      I have a CFormView where I want to display an image and show some buttons over the image. I get the device context for the view, create a compatible bitmap, use the LPPICTURE Render(*) function to display the image file into the DC, then use BitBlt(*) of CDC to display the image. The buttons are placed onto the form. This kind of works, although if I display another window over the form, or move the cursor into the title bar or the system status bar, all the buttons disappear. I would like to place the buttons dynamically, and tried to use SetWindowPos(*) for one of the buttons. But when I called SetWindowPos(*) for that button, everything (image and other buttons) disappeared. Is there a proper way to display buttons over an image so they don't disappear, and also to do so dynamically?

      F Offline
      F Offline
      Fareed Rizkalla
      wrote on last edited by
      #2

      Maybe try on window focus to hide then reshow the buttons. A small workaround!

      G 1 Reply Last reply
      0
      • G genush

        I have a CFormView where I want to display an image and show some buttons over the image. I get the device context for the view, create a compatible bitmap, use the LPPICTURE Render(*) function to display the image file into the DC, then use BitBlt(*) of CDC to display the image. The buttons are placed onto the form. This kind of works, although if I display another window over the form, or move the cursor into the title bar or the system status bar, all the buttons disappear. I would like to place the buttons dynamically, and tried to use SetWindowPos(*) for one of the buttons. But when I called SetWindowPos(*) for that button, everything (image and other buttons) disappeared. Is there a proper way to display buttons over an image so they don't disappear, and also to do so dynamically?

        E Offline
        E Offline
        Eugen Podsypalnikov
        wrote on last edited by
        #3

        There are four questions :) : - where do you draw (what function of the view) ? - where do you create the buttons ? - how do you create the buttons ? - what can you see at the places of the "hidden" buttons ?

        virtual void BeHappy() = 0;

        G 1 Reply Last reply
        0
        • E Eugen Podsypalnikov

          There are four questions :) : - where do you draw (what function of the view) ? - where do you create the buttons ? - how do you create the buttons ? - what can you see at the places of the "hidden" buttons ?

          virtual void BeHappy() = 0;

          G Offline
          G Offline
          genush
          wrote on last edited by
          #4

          I call the functions to draw in the OnDraw(CDC* pDC) function of the CFormView The buttons are put on the form with the resource editor, then I assigned names with class wizard. The image is displayed correctly so it looks like the image is overwriting the buttons. Interestingly, when the cursor is moved to the title bar, the OnDraw gets called, and the buttons disappear. I put in code to detect when the cursor is in the title bar and call Invalidate() in the form to cause OnDraw to be called again, then the buttons are displayed.

          E 1 Reply Last reply
          0
          • G genush

            I call the functions to draw in the OnDraw(CDC* pDC) function of the CFormView The buttons are put on the form with the resource editor, then I assigned names with class wizard. The image is displayed correctly so it looks like the image is overwriting the buttons. Interestingly, when the cursor is moved to the title bar, the OnDraw gets called, and the buttons disappear. I put in code to detect when the cursor is in the title bar and call Invalidate() in the form to cause OnDraw to be called again, then the buttons are displayed.

            E Offline
            E Offline
            Eugen Podsypalnikov
            wrote on last edited by
            #5

            Please try to set WS_CLIPCHILDREN style to your form (possible from the resource editor too) :)

            virtual void BeHappy() = 0;

            G 2 Replies Last reply
            0
            • E Eugen Podsypalnikov

              Please try to set WS_CLIPCHILDREN style to your form (possible from the resource editor too) :)

              virtual void BeHappy() = 0;

              G Offline
              G Offline
              genush
              wrote on last edited by
              #6

              That worked! Thanks!!

              1 Reply Last reply
              0
              • E Eugen Podsypalnikov

                Please try to set WS_CLIPCHILDREN style to your form (possible from the resource editor too) :)

                virtual void BeHappy() = 0;

                G Offline
                G Offline
                genush
                wrote on last edited by
                #7

                Oops, I was a little hasty. I also show static text below the button. I call OnCtlColor(*) and set the hbr (HBRUSH) returned to a hollow brush. The text is then displayed over the image. After setting WS_CLIPCHILDREN, the text background is no longer transparent but light gray.

                E 1 Reply Last reply
                0
                • F Fareed Rizkalla

                  Maybe try on window focus to hide then reshow the buttons. A small workaround!

                  G Offline
                  G Offline
                  genush
                  wrote on last edited by
                  #8

                  I'm sorry, I don't understand. Do you mean call SetFocus() for the buttons?

                  1 Reply Last reply
                  0
                  • G genush

                    Oops, I was a little hasty. I also show static text below the button. I call OnCtlColor(*) and set the hbr (HBRUSH) returned to a hollow brush. The text is then displayed over the image. After setting WS_CLIPCHILDREN, the text background is no longer transparent but light gray.

                    E Offline
                    E Offline
                    Eugen Podsypalnikov
                    wrote on last edited by
                    #9

                    Hmm... So the style can not be accepted :) - How about EnumChildWindows(..) (at the ending of your drawing procedure) and RedrawWindow(..) for each child in its (of EnumChildWindows(..)) callback function ?

                    virtual void BeHappy() = 0;

                    G 1 Reply Last reply
                    0
                    • E Eugen Podsypalnikov

                      Hmm... So the style can not be accepted :) - How about EnumChildWindows(..) (at the ending of your drawing procedure) and RedrawWindow(..) for each child in its (of EnumChildWindows(..)) callback function ?

                      virtual void BeHappy() = 0;

                      G Offline
                      G Offline
                      genush
                      wrote on last edited by
                      #10

                      I did something similar. After the drawing procedure, I have each button redraw itself, and this appears to be working. Thanks to all for your time and help! :)

                      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