I am trying to create a form in C# that is fully transparent, but will not allow clicks to go through it to the other windows below. I have found two methods that were promising, but did not achieve the results I wanted.
The first is by setting the background color and transparency key to the same value. This gives me the transparent form, but clicking goes through.
this.BackColor = Color.Red;
this.TransparencyKey = Color.Red;
The other thing I tried is to set the opacity of the form to 1%. This creates the effects I wanted - almost. I get a 99% transparent form, but there is a slight color alteration to whatever is underneath the form. Since the app I am making is meant to be used in color-sensitive context (graphic design and such), even a tiny alteration of the colors is unacceptable. So I turn to you, dear SO. Can this be done?
I have found the solution, and I am sharing it with you guys as well.
The answer was quite simple: I set: this.TransparencyKey = Color.Lime;
And then I used a 1x1px Lime PNG as the background image. This also has the added benefit of not obscuring the form border and title bar. I will remove them later, but at the moment, it's useful to know where the form is located.
I found a solution to this completely by accident.
I wanted a click through transparent window and got it by using the answer in this SO question:
C# cursor highlighting/follower
That answer uses a transparency filter of LightGreen, but I thought that I might need to use that Color so I changed it to AliceBlue and click through stopped working. I switched back to LightGreen and it started working again.
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