S
Simon
Hey gang.
I am working on making a transparent panel control. How this control works
is making itself invisible then invalidating its parent.
This works great until you get panels in panels & using auto scroll on the
Panel because the flickering that occurs when scrolling.
I am thinking this is because its invalidating a parent which invalidates
its parent etc and I believe its probably getting up to invalidating the form
level.
I am trying to achieve Panels that are transparent so if there is a
PictureBox behind them, it will show through.
As follows:
protected override void OnPaintBackground(PaintEventArgs e)
{
if (this.BackColor == Color.Transparent)
return;
base.OnPaintBackground(e);
}
protected override void OnPaint(PaintEventArgs e)
{
if (this.BackColor == Color.Transparent)
{
if (!isPaintBackgroundComplete)
{
this.Visible = false;
this.Parent.Invalidate(Bounds);
this.Parent.Update();
this.Visible = true;
isPaintBackgroundComplete = true;
return;
}
isPaintBackgroundComplete = false;
}
}
Is there a better way to achieve this? As mentioned this mostly flickers
when scrolling because I think its invalidating 2-3-4 parents up to the form
level.
Is there any PInvoke support that could help out here? I could not find
anything on google. Everything I saw was for the full framework.
I would appreciate any help.
Thanks and take care.
I am working on making a transparent panel control. How this control works
is making itself invisible then invalidating its parent.
This works great until you get panels in panels & using auto scroll on the
Panel because the flickering that occurs when scrolling.
I am thinking this is because its invalidating a parent which invalidates
its parent etc and I believe its probably getting up to invalidating the form
level.
I am trying to achieve Panels that are transparent so if there is a
PictureBox behind them, it will show through.
As follows:
protected override void OnPaintBackground(PaintEventArgs e)
{
if (this.BackColor == Color.Transparent)
return;
base.OnPaintBackground(e);
}
protected override void OnPaint(PaintEventArgs e)
{
if (this.BackColor == Color.Transparent)
{
if (!isPaintBackgroundComplete)
{
this.Visible = false;
this.Parent.Invalidate(Bounds);
this.Parent.Update();
this.Visible = true;
isPaintBackgroundComplete = true;
return;
}
isPaintBackgroundComplete = false;
}
}
Is there a better way to achieve this? As mentioned this mostly flickers
when scrolling because I think its invalidating 2-3-4 parents up to the form
level.
Is there any PInvoke support that could help out here? I could not find
anything on google. Everything I saw was for the full framework.
I would appreciate any help.
Thanks and take care.