Click here to Skip to main content
Licence GPL3
First Posted 8 Apr 2008
Views 40,089
Bookmarked 32 times

Fullscreen the form in VB.NET using a class

By , | 26 Jun 2010 | Article
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.

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

'''<summary>
''' It will return current resolution parameters. 
''' It can make a form FULLSCREEN ... 
'''</summary> 
'''IPStudents.Info - Its all about creativity and ideas. 
'''Author  : Yash Bharadwaj and Chander Prakash 
'''Copyright :  Free to use.Don't remove this Sticker.
'''Usage: Just call function fullscreen with form name as parameter.
'''It can detect client resolution as width-x and height-y
'''It can maximize form as fullscreen.
'''You can make form Topmost as optional 
'''<author>Yash Bharadwaj</author>
'''<remarks></remarks>




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 



'You also need an alias to the API function called GetSystemMetrics, like this : 
 Private Declare Function GetSystemMetrics Lib user32.dll Alias GetSystemMetrics (ByVal Which As Integer) As Integer


'Following this you need to declare 4 constants : 
    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


'Then 2 public properties : 

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 

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Authors

chanderp

Software Developer

India India

Member

IPStudents.Info - Its all about creativity and ideas.

Yash Bharadwaj

Software Developer
Speedovation
India India

Member

Follow on Twitter Follow on Twitter
CssEditor.In - Wait less code more.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalanother solution in C# PinmemberSteed Soft4:07 10 Jan '09  
QuestionMe.TopMost ?? Pinmembernetiger200215:31 22 Apr '08  
GeneralNo need for GetSystemMetrics Pinmembermav.northwind2:38 8 Apr '08  
GeneralRe: No need for GetSystemMetrics Pinmemberchanderp2:49 8 Apr '08  
AnswerRe: No need for GetSystemMetrics PinmemberYash Bharadwaj20:38 12 Apr '08  
QuestionWhat is SetWindowPos for? PinmemberRobert Rohde2:08 8 Apr '08  
AnswerRe: What is SetWindowPos for? Pinmemberchanderp2:36 8 Apr '08  
GeneralRe: What is SetWindowPos for? PinmemberRobert Rohde0:04 10 Apr '08  
GeneralRe: What is SetWindowPos for? Pinmembera_pess3:44 25 Oct '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 27 Jun 2010
Article Copyright 2008 by chanderp, Yash Bharadwaj
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid