I have a project where I need to do a layers of Containers.
Container must have something like:
Form.Opacity = 0;
User can see elements under top layer, but can't use them.
I saw many examples with transparent backgrounds, but in my way I'll need to move elements on this Container. Better what I found:
class xPanel : Panel
{
public xPanel()
{
SetStyle(ControlStyles.Opaque, true);
}
protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
return createParams;
}
}
protected override void OnPaint(PaintEventArgs e)
{
//PaintParentBackground(e);
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0, Color.White)),
0, 0, Width, Height);
}
public void InvalidateEx()
{
if (Parent == null)
return;
Rectangle rc = new Rectangle(this.Location, this.Size);
Parent.Invalidate(rc, true);
}
}
But there are trails while drag elements, or blinking on redrawing.
I don't know how to solve this problem. Have ideas?
I use InvalidateEx(), in:
protected override void OnLocationChanged(EventArgs e)
{
if (Parent != null)
((xPanel)Parent).InvalidateEx();
}
Try to add
So do not repaint a background, should, at least, remove blinking.
Hope this helps.