29Mar How to make a full-screen Windows app using VB.NET
Recently I had to write a Windows application that required the main form to run in full-screen mode. This means no title bar and with the window appearance above everything else, i.e. Start Button, taskbar, system tray and all other apps.
This requires an API call to the SetWindowPos function which you need to create an alias to before you can call it. The first part of the code, which should be placed in the declarations part of the form, looks like this :
You also need an alias to the API function called GetSystemMetrics, like this :
Following this you need to declare 4 constants :
Private Const SM_CYSCREEN As Integer = 1
Private Shared HWND_TOP As IntPtr = IntPtr.Zero
Private Const SWP_SHOWWINDOW As Integer = 64
Then 2 public properties :
Get
Return GetSystemMetrics(SM_CXSCREEN)
End Get
End Property
Get
Return GetSystemMetrics(SM_CYSCREEN)
End Get
End Property
After this you need to write a simple sub routine to use the constants you declared above and that calls the SetWindowPos API function. The function’s code looks like this :
Me.WindowState = FormWindowState.Maximized
Me.FormBorderStyle = FormBorderStyle.None
Me.TopMost = True
SetWindowPos(Me.Handle, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW)
End Sub
Beyond that it’s just a case of calling the FullScreen sub routine whenever you want the application to show in full-screen mode.


June 3rd, 2007 at 12:29 am
Thanks, I’ve been looking all over for this
June 9th, 2007 at 6:47 pm
No problem, thanks for the comment.
December 21st, 2007 at 7:53 pm
Perfect.. bless u vb guru’s…

i love google!
December 28th, 2007 at 6:13 pm
good code man, but u dident make for restore mode
January 17th, 2008 at 7:39 pm
This is Maximize mode not Full-screen mode.
January 26th, 2008 at 6:25 pm
As far as I’m aware this IS full-screen mode. There are no titlebars and the Windows taskbar doesn’t show up at all. If anyone has further comments about this article please leave your email address so I can respond - thanks.
- Chris
April 20th, 2008 at 11:05 pm
How do you do to return to normal mode??
April 22nd, 2008 at 4:54 am
I’ve had a couple of requests for the method to change back to normal/restore mode for the application window. The method below will do this for you.
Public Sub NormalMode()
‘ restore the window size back to default
Me.WindowState = FormWindowState.Normal
‘ change the form’s border style so the border is visible
‘ note that SizableToolWindow is just what I’ve used - there are other options available if you have code auto-completion enabled
Me.FormBorderStyle = FormBorderStyle.SizableToolWindow
‘ change the window so it’s not the on top
Me.TopMost = False
End Sub
Note that this method is basically the reverse of the FullScreen() method described above but without the use of the SetWindowPos call.
Please ask if you have any questions about the above code.