Is it possible to create a big white rectangle on the screen, without using a Forms Application?
It should cover the whole screen if possible.
I know I have to use the System.Drawing and tried several steps, but none have actually printed anything to my screen!
Method 1: Call the Windows API
You need
System.DrawingandSystem.Runtime.InteropServices. You may need to add project references to them.Add the methods to your class with P/Invoke
Get a
Graphicsobject for the entire screen and draw a rectangle with it:The problem with this method is that if the screen refreshes at all, the rectangle will be overwritten, making it useless for most practical applications.
Method 2: Create a borderless form
As before, you need a project reference. This time to
System.Windows.Forms. You’ll also needSystem.Drawingagain:Make the new form, remove its borders, fill the screen with it, and put it on top of the taskbar:
A possible issue with this is that the user can just alt+tab away from the window. If you want to do any more complicated graphics, you’ll need to write some drawing code like this. To make the form background transparent, set its
TransparentKeyto the same as itsBackolor.I’ve just tested both of these in .NET 4.5 and Windows 7, so it may be different for earlier versions. More information here and here.