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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How to achieve 'True' transparency with pictureBox??

How to achieve 'True' transparency with pictureBox??

Scheduled Pinned Locked Moved Managed C++/CLI
questiontutorial
8 Posts 2 Posters 2 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.
  • R Offline
    R Offline
    richiemac
    wrote on last edited by
    #1

    Hi all, I've got a form with a number of picture boxes. I now want to add a small picturebox on top of these main boxes and be able to see the main box through the small box. If I set the background colour to transparent it, as you probably know, will show the main forms background. Is there a way that I can set the parent of the small box to be the main box? If not how do I go about creating a picturebox that does have true transparency. I presume I can write my own pictureBox class but don't know how and what I would need to override. Does anyone have any idea because I'm dying here guys!! :)

    C 1 Reply Last reply
    0
    • R richiemac

      Hi all, I've got a form with a number of picture boxes. I now want to add a small picturebox on top of these main boxes and be able to see the main box through the small box. If I set the background colour to transparent it, as you probably know, will show the main forms background. Is there a way that I can set the parent of the small box to be the main box? If not how do I go about creating a picturebox that does have true transparency. I presume I can write my own pictureBox class but don't know how and what I would need to override. Does anyone have any idea because I'm dying here guys!! :)

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

      Forget the stupid picture box and draw your own image onto the screen. Christian Graus - Microsoft MVP - C++

      R 1 Reply Last reply
      0
      • C Christian Graus

        Forget the stupid picture box and draw your own image onto the screen. Christian Graus - Microsoft MVP - C++

        R Offline
        R Offline
        richiemac
        wrote on last edited by
        #3

        So how do I draw a transparent image?

        C 1 Reply Last reply
        0
        • R richiemac

          So how do I draw a transparent image?

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

          Use the DrawImage method that takes an ImageAttributes class instance. That class does many things, transparency is one of them. Christian Graus - Microsoft MVP - C++

          R 1 Reply Last reply
          0
          • C Christian Graus

            Use the DrawImage method that takes an ImageAttributes class instance. That class does many things, transparency is one of them. Christian Graus - Microsoft MVP - C++

            R Offline
            R Offline
            richiemac
            wrote on last edited by
            #5

            Ok, I've used drawimage and imageattributes to make my image transparent. Now how do I float this image over a picturebox control (it seems to be painted under the control). What I'm basically looking for is an image on the form that will change size and position dynamically. I need to be able to set things like cursors when I'm over a certain area of the image. So my idea was to float another image over the top and use this region to set cursors. The only way to use cursors I've found at the moment is by using forms controls (hence the pictureboxes). I've tried using rectangles and regions but I get the same problem as I'm now getting with images - they seem to be hidden under the picture. I've tried overriding picturebox but can't seem to get it working. In fact anything I try doesn't produce the goods.:(

            C 1 Reply Last reply
            0
            • R richiemac

              Ok, I've used drawimage and imageattributes to make my image transparent. Now how do I float this image over a picturebox control (it seems to be painted under the control). What I'm basically looking for is an image on the form that will change size and position dynamically. I need to be able to set things like cursors when I'm over a certain area of the image. So my idea was to float another image over the top and use this region to set cursors. The only way to use cursors I've found at the moment is by using forms controls (hence the pictureboxes). I've tried using rectangles and regions but I get the same problem as I'm now getting with images - they seem to be hidden under the picture. I've tried overriding picturebox but can't seem to get it working. In fact anything I try doesn't produce the goods.:(

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

              richiemac wrote: What I'm basically looking for is an image on the form that will change size and position dynamically. Sounds like you want to write your own control, from the total base class, that draws these images for you. A picture box will not work for this, that's why I said to draw yourself. Christian Graus - Microsoft MVP - C++

              R 1 Reply Last reply
              0
              • C Christian Graus

                richiemac wrote: What I'm basically looking for is an image on the form that will change size and position dynamically. Sounds like you want to write your own control, from the total base class, that draws these images for you. A picture box will not work for this, that's why I said to draw yourself. Christian Graus - Microsoft MVP - C++

                R Offline
                R Offline
                richiemac
                wrote on last edited by
                #7

                Could you please point me towards a good tutorial on this subject as I'm totally new to this stuff. From what I gather I would have to write my own paint events - is that right??

                C 1 Reply Last reply
                0
                • R richiemac

                  Could you please point me towards a good tutorial on this subject as I'm totally new to this stuff. From what I gather I would have to write my own paint events - is that right??

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

                  That's right. If you search this site for user control, you'll get heaps of hits. This[^] and this[^] look like good places to start. Christian Graus - Microsoft MVP - C++

                  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