This article provides an approach to a Transparent Control that draws an ellipse with real transparent background and a brush that supports transparent colors.
Below sample project is included in the ZIP file. In addition, you will find a file that contains the control TranspControl.ddl. It was made and based on technique presented in this article.
To make a transparent control you may create a default control and proceed with the following steps:
1. Add the transparent style to the control window.
Protected override CreateParams CreateParams 2. Override the OnPaintBackground event. This is necessary to prevent the background to be painted.
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
Protected override void OnPaintBackground(PaintEventArgs e) 3. Override the OnMove event with the following code.
// do nothing
Protected override void OnMove(EventArgs e)