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#
  4. Draw bitmap on top

Draw bitmap on top

Scheduled Pinned Locked Moved C#
graphicsjsontutorialquestion
8 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.
  • _ Offline
    _ Offline
    __John_
    wrote on last edited by
    #1

    Hi, I want to draw a bitmap on my form, on top of the other controls, however I try to do it, it always gets drawn before the rest of the form and its controls. Does anyone know how to draw it on top? Thanks.

    “If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford

    D 1 Reply Last reply
    0
    • _ __John_

      Hi, I want to draw a bitmap on my form, on top of the other controls, however I try to do it, it always gets drawn before the rest of the form and its controls. Does anyone know how to draw it on top? Thanks.

      “If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Put a Panel on the form and call BringToFront on it, then your bitmap image on the Panel. If you draw a bitmap on the form itself, it's gets drawn on the surface of the form, which sits behind all controls on the form.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      L _ 2 Replies Last reply
      0
      • D Dave Kreskowiak

        Put a Panel on the form and call BringToFront on it, then your bitmap image on the Panel. If you draw a bitmap on the form itself, it's gets drawn on the surface of the form, which sits behind all controls on the form.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        interaction with the Form's Controls may become a bit difficult... He'll be back with more questions! :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum


        Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.

        D 1 Reply Last reply
        0
        • L Luc Pattyn

          interaction with the Form's Controls may become a bit difficult... He'll be back with more questions! :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum


          Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Yeah, I was thinking about that, then said to myself, "What do I care if the design sounds fishy? It's not my app!" :-D

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          1 Reply Last reply
          0
          • D Dave Kreskowiak

            Put a Panel on the form and call BringToFront on it, then your bitmap image on the Panel. If you draw a bitmap on the form itself, it's gets drawn on the surface of the form, which sits behind all controls on the form.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            _ Offline
            _ Offline
            __John_
            wrote on last edited by
            #5

            Thanks Dave, Using a pannel is basicaly the same a using a picture control, either way the bitmap is not shown with a transparent background so the controls cannot be seen. I probably should have mentioned this requirement. - John

            “If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford

            B D 2 Replies Last reply
            0
            • _ __John_

              Thanks Dave, Using a pannel is basicaly the same a using a picture control, either way the bitmap is not shown with a transparent background so the controls cannot be seen. I probably should have mentioned this requirement. - John

              “If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford

              B Offline
              B Offline
              BobJanova
              wrote on last edited by
              #6

              I think you will have to construct a path that corresponds to the opaque parts of the bitmap and use Control.Region[^]. I thought there was a way to specify a mask for controls but I can't find it.

              1 Reply Last reply
              0
              • _ __John_

                Thanks Dave, Using a pannel is basicaly the same a using a picture control, either way the bitmap is not shown with a transparent background so the controls cannot be seen. I probably should have mentioned this requirement. - John

                “If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                "Transparent" is not transparent in Windows Forms. You cannot set the Backcolor of a control to Transparent and expect to see through the control. It doesn't work that way. Transparent tells the control to take on the background properties of the control that contains it. So, if you set the Backcolor of a Form to Black and the the Backcolor of a Button to Transparent, the Button will be Black, but not because you can now see through the Button. You cannot see controls "through" another control. Why? Because, in Windows Forms, window elements do not waste time painting regions of themselves where another control is obscurring them. Hence, you can't see any controls through the "transparent" regions of an image. The image may be transparent, but the control painting it is not, no matter what the Backcolor property says. Now, WPF is very different. It's not Windows Forms and doesn't have the same limitations. WPF can do what you want, but the learning curve for it is very steep.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                _ 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  "Transparent" is not transparent in Windows Forms. You cannot set the Backcolor of a control to Transparent and expect to see through the control. It doesn't work that way. Transparent tells the control to take on the background properties of the control that contains it. So, if you set the Backcolor of a Form to Black and the the Backcolor of a Button to Transparent, the Button will be Black, but not because you can now see through the Button. You cannot see controls "through" another control. Why? Because, in Windows Forms, window elements do not waste time painting regions of themselves where another control is obscurring them. Hence, you can't see any controls through the "transparent" regions of an image. The image may be transparent, but the control painting it is not, no matter what the Backcolor property says. Now, WPF is very different. It's not Windows Forms and doesn't have the same limitations. WPF can do what you want, but the learning curve for it is very steep.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  _ Offline
                  _ Offline
                  __John_
                  wrote on last edited by
                  #8

                  Hi Dave, Thanks for the info. I am not looking for a tranaparent control. I am drawing the image with Graphics.DrawImage(). I just need to draw it after the the forms controls are drawn so that it is on top. The framework is forcing me to draw it before the rest of the form, I was hoping there might be some way around this. - John

                  “If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford

                  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