Access Form Resize

How do I make an access form automatically resize itself depending on the screen resolution of the monitor? I think there is an API function to do this but I really don't know. Any ideas and samples would be very useful.
lclearyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BrianWrenCommented:
I'm sure that you've thought of this, but who knows....?

Access has--built-in--Auto Resize, and Auto Center, which do this to a degree.  The form will be the right size to show all of its elements, and irrespective of resolution will be centered on the monitor.

Can you be more detailed about what you are trying to do?

Brian
0
tomk120999Commented:
Hi, lcleary, there's some graet utils for this and other things at www.fmsinc.com.  One is called Zoom.  Might be worthwhile to check it out.

good luck as usual...
0
CareyMBilyeuCommented:
Icleary:

Ken Getz's book (Access 97 Developers Handbook) covers the "scaling" of forms pretty good. It starts on page 465 under Screen Resolution. Some of the declares you will use include:

Public Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long


Public Declare Function GetClientRect Lib "user32" Alias "GetClientRect" (ByVal hwnd As Long, lpRect As RECT) As Long


etc. Good luck

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

AlexVirochovskyCommented:
Other way:
1. Get current resolution :
Global Const WM_HORZRES = 8
Global Const WM_VERTRES = 10

Declare Function WM_apiGetDeviceCaps _
Lib "gdi32" Alias "GetDeviceCaps" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
Declare Function WM_apiGetDesktopWindow _
Lib "user32" Alias "GetDesktopWindow" () As Long
Declare Function WM_apiGetDC _
Lib "user32" Alias "GetDC" _
(ByVal hwnd As Long) As Long
Declare Function WM_apiReleaseDC _
Lib "user32" Alias "ReleaseDC" _
(ByVal hwnd As Long, ByVal hdc As Long) As Long
Declare Function WM_apiGetSystemMetrics _
Lib "user32" Alias "GetSystemMetrics" _
(ByVal nIndex As Long) As Long

Function xg_GetScreenResolution(DisplayHeight As Integer, DisplayWidth As Integer) As String
'return the display height and width
'Dim DisplayHeight As Integer
'Dim DisplayWidth As Integer
Dim hDesktopWnd As Long
Dim hDCcaps As Long
Dim iRtn As Integer

'* make API calls to get desktop settings
hDesktopWnd = WM_apiGetDesktopWindow() 'get handle to desktop
hDCcaps = WM_apiGetDC(hDesktopWnd) 'get display context for desktop
DisplayHeight = WM_apiGetDeviceCaps(hDCcaps, WM_VERTRES)
DisplayWidth = WM_apiGetDeviceCaps(hDCcaps, WM_HORZRES)
iRtn = WM_apiReleaseDC(hDesktopWnd, hDCcaps) 'release display context

'MsgBox "Desktop display width is " & DisplayWidth & " pixels."
'MsgBox "Desktop display height is " & DisplayHeight & " pixels."

xg_GetScreenResolution = DisplayWidth & "x" & DisplayHeight

End Function
2. Get old resolution and if old <>
   current, resize form:
Private Sub Convert(x As Integer, xOld As Integer, _
                    y As Integer, yOld As Integer)
   Dim fForm As Form, iControl As Control
   Dim DB As Database
   Dim i As Integer
   Dim xMax As Integer, yMax As Integer
   
   Set DB = CurrentDb()
            DoCmd.OpenForm "MyForm", acDesign, , , acFormPropertySettings, acHidden
     Set fForm = [Forms]![MyForm]
     xMax = 0
     yMax = 0
     For Each iControl In fForm.Controls
          With iControl
             .Height = .Height * y / yOld
             .Width = .Width * x / xOld
             .Left = .Left * x / xOld
             .Top = .Top * y / yOld
             On Error Resume Next
             .FontSize = .FontSize * y / yOld
             If .FontSize < 8 Then .FontSize = 8
             If .ControlType = acLabel Then
                .SizeToFit 'first buttons!
             End If
             xMax = IIf(.Left + .Width > xMax, .Left + .Width, xMax)
             yMax = IIf(.Top + .Height > yMax, .Top + .Height, yMax)
          End With
       'End If
     Next iControl
     fForm.Width = xMax + 10
     fForm.Detail.Height = yMax + 10
     
     DoCmd.Close acForm, "MyForm", acSaveYes
End Sub

Happy New Year. Alex
0
JimMorganCommented:
lcleary:  Welcome to EE.

FMS, as Tom mentioned, makes two resizing products - Form Resizer, which is part of their Access Components package and Sizer, which is a VB 5/6 ActiveX control.  No one to my knowledge has really tried Sizer with Access but with some playing with it might work.

The Forms Resizer will allow a user to increase the size of a form to fill a window with higher resolution.  If there are several subforms within the form, they will resize also.

We have used the product but remed it out while we were developing the product as the ActiveX caused all kinds of additional problems in the development cycle.  We shipped the first release with 800 X 600 resolution and so far, no one has complained about it.

Jim
0
AlexVirochovskyCommented:
Icleary, what do you think about all
prepositions?
0
AlexVirochovskyCommented:
Icleary, sorry, that i answer, what we
want you reaction:
what do you think about all
prepositions? What(and who) helps you ?
Sorry again, Alex
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.