Hello
I have semi transparent panel written in c# for .net 4.0
it work fine on Windows XP,Vista,7 but it doesn't work fine on Windows 8, 8.1.
On Windows 8 and 8.1 the panel is not semitransparent.
Is there anyone who can tell me why?
Here is my code
public class MyPanel : System.Windows.Forms.Panel
{
public MyPanel() : base()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
protected override CreateParams CreateParams
{
get
{
var cp = base.CreateParams;
cp.ExStyle |= 0x00000020;
return cp;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.Clear(System.Drawing.Color.White);
e.Graphics.CopyFromScreen(this.PointToScreen(new Point(0, 0)), new Point(0, 0), new Size(this.Width, this.Height));
e.Graphics.FillRectangle(new SolidBrush(System.Drawing.Color.FromArgb(120, System.Drawing.Color.Gray)), new Rectangle(new Point(0, 0), this.Size));
}
}