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. Transparent Pictureboxes

Transparent Pictureboxes

Scheduled Pinned Locked Moved C#
questioncsharpcom
5 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.
  • J Offline
    J Offline
    Jordanwb
    wrote on last edited by
    #1

    I have a class called "Card" (as in a deck of cards), which extends the PictureBox class. Now the picturebox is the size of the image (150X215). When you mouse over the card it "hovers" (its Y location decreases 20 pixels) and is supposed to show part of the card underneath it. However this does not happen. See this picture: http://img199.imageshack.us/i/cardsj.jpg/[^] I've done this in the OnLoad event of the Card class: this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; But it doesn't work (as you can see in the picture). I found this article: http://www.codeproject.com/combobox/TransListBox.asp[^] But how do I do this in C#? BTW the images are transparent png's.

    C 1 Reply Last reply
    0
    • J Jordanwb

      I have a class called "Card" (as in a deck of cards), which extends the PictureBox class. Now the picturebox is the size of the image (150X215). When you mouse over the card it "hovers" (its Y location decreases 20 pixels) and is supposed to show part of the card underneath it. However this does not happen. See this picture: http://img199.imageshack.us/i/cardsj.jpg/[^] I've done this in the OnLoad event of the Card class: this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; But it doesn't work (as you can see in the picture). I found this article: http://www.codeproject.com/combobox/TransListBox.asp[^] But how do I do this in C#? BTW the images are transparent png's.

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

      Using pictureboxes for this, is a little insane. Just draw your cards onto your form in your paint event.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      J L 2 Replies Last reply
      0
      • C Christian Graus

        Using pictureboxes for this, is a little insane. Just draw your cards onto your form in your paint event.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        J Offline
        J Offline
        Jordanwb
        wrote on last edited by
        #3

        I've changed it from PictureBox to Panel and added this:

        protected override void OnPaint(PaintEventArgs pe)
        {
        base.OnPaint(pe);

        pe.Graphics.DrawImage(this.card\_image, new Point(0, 0));
        

        }

        But it's still not transparent. Do you want to look at my code?

        C 1 Reply Last reply
        0
        • J Jordanwb

          I've changed it from PictureBox to Panel and added this:

          protected override void OnPaint(PaintEventArgs pe)
          {
          base.OnPaint(pe);

          pe.Graphics.DrawImage(this.card\_image, new Point(0, 0));
          

          }

          But it's still not transparent. Do you want to look at my code?

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

          No, I want you to do what I suggested. DON'T put the images inside a control, draw them on your form directly, in your paint event.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          1 Reply Last reply
          0
          • C Christian Graus

            Using pictureboxes for this, is a little insane. Just draw your cards onto your form in your paint event.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

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

            Christian Graus wrote:

            Using pictureboxes for this, is a little insane

            ftfy :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            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