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. creating a truly transparent control

creating a truly transparent control

Scheduled Pinned Locked Moved C#
questiontutorial
3 Posts 2 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.
  • M Offline
    M Offline
    melanieab
    wrote on last edited by
    #1

    Hi, Easy question here. I found this online, but (I'm still new to programming) I'm not sure how to use it. protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT return cp; } } Do I create a new class for this code? Either way, how and where do I say that I want a label (not all labels) to be this way. Thanks so much!!! Mel :)

    M 1 Reply Last reply
    0
    • M melanieab

      Hi, Easy question here. I found this online, but (I'm still new to programming) I'm not sure how to use it. protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT return cp; } } Do I create a new class for this code? Either way, how and where do I say that I want a label (not all labels) to be this way. Thanks so much!!! Mel :)

      M Offline
      M Offline
      melanieab
      wrote on last edited by
      #2

      Hi again, Ok, I created a class and put the code in it. public class TransparentControl : Label { protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT return cp; } } } Back in the normal form, I made the label private TransparentControl label7; and changed the appropriate line in InitializeComponent() this.label7 = new HCAUT.TransparentControl();. I also made the backcolor of the label Transparent. But when I run everything, the label's backcolor still isn't transparent. Can anyone see what I'm doing wrong? Thanks again, Mel

      M 1 Reply Last reply
      0
      • M melanieab

        Hi again, Ok, I created a class and put the code in it. public class TransparentControl : Label { protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT return cp; } } } Back in the normal form, I made the label private TransparentControl label7; and changed the appropriate line in InitializeComponent() this.label7 = new HCAUT.TransparentControl();. I also made the backcolor of the label Transparent. But when I run everything, the label's backcolor still isn't transparent. Can anyone see what I'm doing wrong? Thanks again, Mel

        M Offline
        M Offline
        microsoc
        wrote on last edited by
        #3

        hi melanieab! :) i think if you inherited the Label, it already supports transparency. try to remove the override property you've added. if still doesn't allow transparency, add this line of code on the constructor of your control.

        SetStyle(ControlStyles.SupportsTransparentBackColor, true)

        hope that helps! :) microsoc :cool:

        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