5

I'm working in C#, in Visual Studio, and I'm trying to make a transparent form - entirely transparent, though not click-through - without making the title bar transparent, so that there's still something to move the (invisible) window around and (most importantly) close it.

It'd also be nice if the window had visible borders, but that may be a separate question.

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
linkhyrule5
  • 871
  • 13
  • 29

1 Answers1

10

If I understand your question correctly, you can Use TrancparencyKey

Set TrancparencyKey and BackColor properties both to same color like Color.Red.

Here is the screenshot of transparent form over visual studio:

enter image description here

Note:

  • When you use for example Color.Red every thing works fine and you can handle mouse Click. But the behavior is different for different colors, for example Color.Magenta the form can not capture the mouse Click.
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
  • 2
    Both settings can be found under Properties of your Form. – Nebula Sep 25 '15 at 13:34
  • On my system (Windows 10 with VS Community 2015) I did not need the `this.Capture` part. The Form was transparent in the middle, but already capturing the mouse click by default (I updated the click position in the Form's title bar). – Idle_Mind Sep 25 '15 at 14:25
  • 1
    @Idle_Mind When you use for example `Color.Red` every thing works fine and also it seems there is no need to set `Capture=true`. Behavior is different for different colors, for example `Color.Magenta` the form can not capture the mouse click. – Reza Aghaei Sep 25 '15 at 16:09
  • That is *weird*. I assume there's something underlying that, I'll have to dig into it... – linkhyrule5 Sep 26 '15 at 04:36
  • 1
    @link http://stackoverflow.com/questions/4448771/c-sharp-form-transparencykey-working-different-for-different-colors-why – Cody Gray - on strike Jul 10 '16 at 15:33