Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Make a form cover the entire screen


Private Declare Function SetWindowPos Lib "user32" ( ByVal hwnd As Long , _
     ByVal hWndInsertAfter As Long , ByVal x As Long , ByVal y As Long , ByVal cx As Long , _
     ByVal cy As Long , ByVal wFlags As Long ) As Long
Private Declare Function GetSystemMetrics Lib "user32" ( ByVal nIndex As Long ) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Const HWND_TOP = 0
Const SWP_SHOWWINDOW = &H40

Dim cx As Long
Dim cy As Long
Dim RetVal As Long
' Determine if screen is already maximized.
If Me .WindowState = vbMaximized Then
  ' Set window to normal size
  Me .WindowState = vbNormal
End If          ' Get full screen width.
cx = GetSystemMetrics(SM_CXSCREEN)          ' Get full screen height.
cy = GetSystemMetrics(SM_CYSCREEN)
' Call API to set new size of window.
RetVal = SetWindowPos( Me .hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW)