PDA

View Full Version : form - fullscreen



eran3185
04-25-2007, 11:03 PM
hey
i want that my form will open all over the screen (not depend on the resolution of the screen).
how can i do this command ?

Aussiebear
04-26-2007, 12:28 AM
Hi eran3185,

Try Application.DisplayFullScreen

Bob Phillips
04-26-2007, 12:44 AM
Here is some code that adds maximize and minimize buttons to a form so that the user can do it themselves



Option Explicit
'Windows API calls
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) 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 GetSystemMenu Lib "user32" ( _
ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare Function SetFocus Lib "user32" ( _
ByVal hWnd As Long) As Long

'Window styles
Private Const GWL_STYLE As Long = (-16)
Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000

'Close menu item
Private Const SC_CLOSE As Long = &HF060

'Hide or show a window
Private Const SW_HIDE As Long = 0
Private Const SW_SHOW As Long = 5

'Windows messages
Private Const WM_SETICON = &H80

Private Sub SetFormStyle()
Dim hWnd As Long
Dim lStyle As Long

If Val(Application.Version) < 9 Then
hWnd = FindWindow("ThunderXFrame", Me.Caption) 'XL97
Else
hWnd = FindWindow("ThunderDFrame", Me.Caption) 'XL2000+
End If

lStyle = GetWindowLong(hWnd, GWL_STYLE) Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX

SetWindowLong hWnd, GWL_STYLE, lStyle
lStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
SetWindowLong hWnd, GWL_EXSTYLE, lStyle
DrawMenuBar hWnd
SetFocus hWnd

End Sub

Charlize
04-26-2007, 12:50 AM
In normal module
Option Explicit
Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex&) As Long
Sub go_for_it()
UserForm1.Show
End Sub
In userform activate module
Private Sub UserForm_Activate()
With Me
.Left = 0
.Width = GetSystemMetrics32(0) * 0.75
.Top = 0
.Height = GetSystemMetrics32(1) * 0.75
End With
End SubCharlize