Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Static fHeight As Single
Static fWidth As Single
Static fLeft As Single
Static fTop As Single
Static fStyle As Long
If (KeyCode = vbKeyReturn) And (Shift And vbAltMask) Then
If fStyle Then
SetWindowLong hwnd, -16&, fStyle
WindowState = vbNormal
Height = fHeight
Width = fWidth
Left = fLeft
Top = fTop
fStyle = 0
Else
fTop = Top
fLeft = Left
fWidth = Width
fHeight = Height
fStyle = SetWindowLong(hwnd, -16&, &H16000000)
WindowState = vbMaximized
End If
End If
End Sub