5 Replies - 1395 Views - Last Post: 01 December 2010 - 03:25 PM Rate Topic: -----

#1 Ahmedn1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 23
  • View blog
  • Posts: 556
  • Joined: 04-August 09

Creating a transparent Control

Posted 26 November 2010 - 05:22 PM

I'm creating a new control to my project
and I need to add the Opacity property to that control so that the user can modify its opacity by moving a slider

I searched for this and all what I found are examples to produce a static transparent control using this code

public StopWatch()
        {
            InitializeComponent();
            SetScrollState((int)ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.Transparent;
        }

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;

                cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT

                return cp;
            }
        }

        protected void InvalidateEx()
        {

            if (Parent == null)

                return;

            Rectangle rc = new Rectangle(this.Location, this.Size);

            Parent.Invalidate(rc, true);

        }

        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            
            //do not allow the background to be painted 

        }



it is always transparent
I need it dynamic like the opacity property of Windows Forms

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a transparent Control

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,466
  • Joined: 29-May 08

Re: Creating a transparent Control

Posted 26 November 2010 - 05:33 PM

I doubt it being possible in WinForms. WPF can don't natively.
Was This Post Helpful? 0
  • +
  • -

#3 Ahmedn1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 23
  • View blog
  • Posts: 556
  • Joined: 04-August 09

Re: Creating a transparent Control

Posted 26 November 2010 - 05:36 PM

View PostAdamSpeight2008, on 26 November 2010 - 04:33 PM, said:

I doubt it being possible in WinForms. WPF can don't natively.


There are applications that I use and have transparent controls
like 'Xnote Stopwatch' this application gives the user the control to change the transparency of the stopwatch control (Panel, textboxes, labels)
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,466
  • Joined: 29-May 08

Re: Creating a transparent Control

Posted 26 November 2010 - 06:52 PM

That effect and program can be created just using the form alone, no additional controls or panels.
Was This Post Helpful? 0
  • +
  • -

#5 Ahmedn1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 23
  • View blog
  • Posts: 556
  • Joined: 04-August 09

Re: Creating a transparent Control

Posted 26 November 2010 - 10:26 PM

View PostAdamSpeight2008, on 26 November 2010 - 05:52 PM, said:

That effect and program can be created just using the form alone, no additional controls or panels.


In the program I mentioned you can create many stopwatch counters (So I don't think that each is a form)
Was This Post Helpful? 0
  • +
  • -

#6 Ahmedn1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 23
  • View blog
  • Posts: 556
  • Joined: 04-August 09

Re: Creating a transparent Control

Posted 01 December 2010 - 03:25 PM

No ideass?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1