CodeItBetter Programming Another VB Programming Blog

How to Maximize the Form to Full Screen

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'Forms - How to Maximize the Form to Full Screen

Option Explicit
 
'Add 2 Command Buttons to your form. The first one is to view the form in Full screen,
'and the second one is for regular maximizied view.

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
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOP = 0
Public Const SWP_SHOWWINDOW = &H40
 
Private Sub Command1_Click()
    Dim ll_Width As Long, ll_Height As Long
    If Me.WindowState = vbMaximized Then
        WindowState = vbNormal
    End If
    ll_Width = GetSystemMetrics(SM_CXSCREEN)
    ll_Height = GetSystemMetrics(SM_CYSCREEN)
    Call SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, ll_Width, ll_Height, SWP_SHOWWINDOW)
End Sub
 
Private Sub Command2_Click()
    WindowState = vbMaximized
End Sub
Filed under: Forms Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.