Introduction
Fullscreen the form in VB.NET using a class
In some application we need to fullscreen the App .Here is
simple class that can fullscreen any App. Just create a variable of this class
type and call the function using the class variable.
Using the code
Public Class FullscreenClass
Public Declare Function SetWindowPos Lib user32.dll Alias SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndIntertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags
As Integer) As Boolean
Private Declare Function GetSystemMetrics Lib user32.dll Alias GetSystemMetrics (ByVal Which As Integer) As Integer
Private Const SM_CXSCREEN As Integer = 0
Private Const SM_CYSCREEN As Integer = 1
Public Shared HWND_TOP As IntPtr = IntPtr.Zero
Public Const SWP_SHOWWINDOW As Integer = 64
Public ReadOnly Property ScreenX() As Integer
Get
Return
GetSystemMetrics(SM_CXSCREEN)
End Get
End Property
Public ReadOnly Property ScreenY() As Integer
Get
Return
GetSystemMetrics(SM_CYSCREEN)
End Get
End Property
Public Sub FullScreen(ByVal frm As Form, ByVal boolTopOptional As Boolean)
frm.WindowState = FormWindowState.Maximized
frm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.TopMost = boolTopOptional
SetWindowPos(frm.Handle, HWND_TOP, 0,0, ScreenX, ScreenY, SWP_SHOWWINDOW)
End Sub
End Class
---------------------------------------------------------------------------------
Updated Making fullscreen using Screen class
Public Class classFullScreen
Dim varScreen As Screen
Dim intWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim intHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim intTop As Integer = 0
Dim intLeft As Integer = 0
Dim intX As Integer = 0
Dim intY As Integer = 0
Public Function FullscreenTheForm(ByVal frm As Form)
frm.Top = intTop
frm.Left = intLeft
frm.Width = intWidth + 40
frm.Height = intHeight
frm.FormBorderStyle = FormBorderStyle.None
Return 0
End Function
End Class
Now problem is -> The bottom window bar is above on form.I'm trying to resolve this issue also.
Thank you mav and robert for your comments.
Points of Interest
CSS Editor.in - Wait less code more