I set out to write small desktop app for myself. Strangely there are very few resources or explanations online how to write full screen apps in VB.Net or any other .Net . It is not a game FYI but if someone would like to write one, he would want his game to be full-screen.
If this code proves any good (when finished) I might open-source it as well but this is not why I am posting this.
Main reason for my post is that explanations I found online are really confusing, I guess because it is very easy, no-one wrote about it and other people googling are finding only how it was done for VB6, for which you need to hook into user32.dll , still not overly complicated but total overkill comparing to this.
In order to get your app to full-screen mode, here is what you need to say:
Me.MaximizeBox = False Me.MinimizeBox = False Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None Me.WindowState = FormWindowState.Maximized
Now, let’s say you want to alternate between full-screen and normal, you would write:
Sub SwitchStates() If Me.WindowState <> FormWindowState.Maximized Then Me.MaximizeBox = False Me.MinimizeBox = False Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None Me.WindowState = FormWindowState.Maximized Else Me.MaximizeBox = True Me.MinimizeBox = True Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable Me.WindowState = FormWindowState.Normal End If End Sub
Let’s say now that you want to switch to full-screen when user presses F11 (I can’t be more obvious then this):
If e.KeyValue = Keys.F11 Then SwitchStates() End If
You would of course tie this to KeyUp event.
All very simple things, the only reason for writing is that when I found confusing info on how to do those things.