I've already seen Transparent background on winforms?
it doesnt offer solution to my problem. I am using the same method to try to achieve transparency
public Form1()
{
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
this.BackColor = Color.FromArgb(0, 0, 0, 0);
}
But this gives a grey background, not transparent. How can I get an actually transparent background (note, transparency key solutions do not give a transparent background, and when I paint with alpha channel less than 255, it blends with the set form background colour, and not the actual background)? I want to paint to certain regions of the screen with alpha < 255 and blend with the background (not the form).
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
It was mainly developed as a system programming language to write an operating system. The main features of the C language include low-level memory access, a simple set of keywords, and a clean style, these features make C language suitable for system programmings like an operating system or compiler development.
Quote from wikipedia: "A successor to the programming language B, C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to construct utilities running on Unix." The creators want that everyone "see" his language. So he named it "C".
The way I did it long time ago was to find an unused color for the form background and then set the transparency key to it:
this.BackColor = Color.Magenta;
this.TransparencyKey = Color.Magenta;
Other ways are:
[EDIT] As Mario states, normally the default transparent color for the key is Magenta.
This is the best way to make the transparent background of winform.
right after this:
public partial class frmTransparentBackcolor : Form
{
public frmTransparentBackcolor()
{
InitializeComponent();
//set the backcolor and transparencykey on same color.
this.BackColor = Color.LimeGreen;
this.TransparencyKey = Color.LimeGreen;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.LimeGreen, e.ClipRectangle);
}
}
hope this will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With