Rendere un Form FullScreen

In un modulo Bas inserire:

Option Explicit

'Routine e definizioni costanti e definizione chiamate API
Private Const WS_DLGFRAME = &H400000
Private Const WS_THICKFRAME = &H40000
Private Const WS_VISIBLE = &H10000000
Private Const GWL_STYLE = (-16)
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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 GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Public Sub ToggleFullScreen(ByVal lngHwnd As Long)
Static boolStatoWindows As Boolean
Static lngOrigStyle As Long
Static rectOrig As RECT
Dim lngNewStyle As Long
boolStatoWindows = Not boolStatoWindows
If boolStatoWindows Then
    lngOrigStyle = GetWindowLong(lngHwnd, GWL_STYLE)
    GetWindowRect lngHwnd, rectOrig
    lngNewStyle = lngOrigStyle
    lngNewStyle = lngNewStyle - WS_DLGFRAME
    lngNewStyle = lngNewStyle - WS_THICKFRAME
    lngNewStyle = lngNewStyle Or WS_VISIBLE
    SetWindowLong lngHwnd, GWL_STYLE, lngNewStyle
    SetWindowPos lngHwnd, vbNull, 0, 0,   GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_DRAWFRAME
Else
    SetWindowLong lngHwnd, GWL_STYLE, lngOrigStyle
    SetWindowPos lngHwnd, vbNull, rectOrig.Left, rectOrig.Top, rectOrig.Right - rectOrig.Left, rectOrig.Bottom - rectOrig.Top, SWP_DRAWFRAME
End If
End Sub


Form demo per la visualizzazione di finestre in full-screen premi F11 per attivare o disattivare il full-screen:

Option Explicit

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF11 Then
    ToggleFullScreen Me.hwnd
    Me.ZOrder 0
End If
End Sub

Testato su: Windows 98, Windows Me, Windows 2000 Professional