I made a transparent panel like this (in C#) :
public class TransparentPanel : Panel
{
public TransparentPanel()
{
}
protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
return createParams;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
// Do not paint background.
}
}
It is displayed over a normal Panel. I want to draw a circle to show something in the other panel, so I draw my circle on the transparent 's OnPaint method. Then, I want to show something else, so I need this circle to "move" somewhere else.
But I can't.
None of the solutions I could find here worked for me, though I do draw this circle in the OnPaint method. I do not use the Graphics object of the event, because if I do, nothing is displayed at all.
So, I have to use this:
this.CreateGraphics()
I can't draw another circle over it, using the background color : my background needs to stay transparent. And drawing a circle with Color.Transparent doesn't work.
Clearing the transparent panel results in a black background replacing the transparent one.
The instruction
Graphics.Clear();
doesn't compile.
Neither does this one :
gr.Clear();
because it needs a Color parameter.
And this:
gr.Clear(Color.transparent);
creates a black background.
Seems to me I have tried everything I could think of.
Any idea ?