Maximizing Userforms to suit any screen size

A

assertec

Hi all,

I was wondering if it is possible to get a userform to maximize itself
automatically (to fill the entire screen) when it is activated.

Currently I set my userforms properties width to be 417.75 and height
to be 600 - which is fine for some screens but not for others. It would
be better if I include some code that could determine the users screen
resolution - and then maximize the userform automatically to fill the
entire screen of any end-user, no matter what the size or the
resolution setting.

Thanks for any help with this

Regards
Karen
 
J

Jim Cone

Karen
If you adjust the lngSize values then this could be close to what you want.
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


'---------------------------------------------
'Insert these three lines at top of module.
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1

'--------------------------------------------
Public Function GetSR() As String
GetSR = CStr(GetSystemMetrics(SM_CXSCREEN)) & " x " & _
CStr(GetSystemMetrics(SM_CYSCREEN))
End Function
'-------------------------------------------

Sub ResizeForm()
' Jim Cone - San Francisco, USA
Dim lngSize As Long
Dim strSR As String
Dim lngMax As Long

strSR = GetSR
lngMax = Val(strSR)

If lngMax > 1200 Then
lngSize = 100
ElseIf lngMax > 1000 Then
lngSize = 80
ElseIf lngMax > 799 Then
lngSize = 70
Else
lngSize = 50
End If

UserForm1.Zoom = lngSize
UserForm1.Width = UserForm1.Width * (lngSize / 100)
UserForm1.Height = UserForm1.Height * (lngSize / 100)
UserForm1.Show
Unload UserForm1
Set UserForm1 = Nothing
End Sub
'-------------------------------------------


Hi all,
I was wondering if it is possible to get a userform to maximize itself
automatically (to fill the entire screen) when it is activated.
Currently I set my userforms properties width to be 417.75 and height
to be 600 - which is fine for some screens but not for others. It would
be better if I include some code that could determine the users screen
resolution - and then maximize the userform automatically to fill the
entire screen of any end-user, no matter what the size or the
resolution setting.
Thanks for any help with this
Regards
Karen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top