How would I go about creating a dynamic "hole" in a windows form through which the user could see the actual desktop instead of the form? Right now I've created a translucent form on top of the entire screen and I'm looking to see through that translucent form.
Asked
Active
Viewed 1,534 times
2 Answers
12
Use the form's Region property.
Rectangle rect = new Rectangle(Point.Empty, this.Size);
Region region = new Region(rect);
rect.Inflate(-1 * (this.Width / 3), -1 * (this.Height / 3));
region.Exclude(rect);
this.Region = region;
That should put a hole through your form.

Simon
- 25,468
- 44
- 152
- 266
-
Excellent answer! Simple and nice! – Nikos Steiakakis Feb 01 '10 at 14:51
-
Most splendid, sir! Thanks a lot! – Robert Synoradzki Jul 15 '19 at 18:58
5
As an alternative if you need rectangular form of "hole" you can set form's TransparencyKey
property to a certain color and then create a Panel with the background of the same color. (That panel will be transparent on run.)

Regent
- 5,502
- 3
- 33
- 59