Full Version: Auto resize the form based on your size of your monitor
UtterAccess Forums > Microsoft® Access > Access Forms
big0
I've been doing some research on how to resize my form or any forms automatically based on the user monitor (Tower) or the size of a laptop screen 15 inches or 17 inches etc.
The problem that I keep happening is that users have laptops now with a docking station. On there desk they have 17 inch monitors, but if they work from home and use there laptop there laptop screen is only 15 inch.
My form does not properly fit inside the window of the laptop.
Can anyone direct me on how to resize my window automatically. Other words, if my user comes in the office and use there docking station with a 17 inch monitor the form fits within its height of the window as well as the width. If my users decide to work from home using there laptops, i want a way that my forms open according to the size of the laptop screen.
BIG0
big0
Im using Access 2003
theDBguy
Hi,
heck out these previous threads:
01
02
03
04
05
Hope that helps...
big0
theDBguy
Have you used Form Resize?
Form Resizer: Help
(FREEWARE)
The Form Resizer is a Microsoft® Access® MDB (Microsoft Database) that allows you to install a module in your own Access MDBs that can resize your program's forms to fit the current screen resolution

Thanks
theDBguy
Hi,
So, I haven't had a need to resize my forms yet. I always try to design my forms to the least/most common screen resolution for all the users.
Cheers
HiTechCoach
I have found That is just to many possible configurations to worry about. I have many users with dual monitor an d the two monitors are not hte same size. A some that are the same size monintor have one monitor rotated 90 degrees.
There are also control that do not resize well.
This has been an issue with developers for web pages and other software platforms besides Access.
Ofollow the same method that theDBguy uses. All the professional developers I work with that develop software UI's (not just with Access) and also web site UI, myself included develop the UI design the for smallest/ common screen resolution that you want to support.
I have made a very specialized front end that I create in multiple versions. Each version was formatted to a specific screen resolution/size.

I find that if you do not every set your forms to maximized, instead use .movesize to set the forms to appear at the maximized desired size, they will retain their size at larger resolutions. IMHO, this looks better than if maximized with lots of blank space on the form.
big0
wow....This is the first time i experience this...
So i will change DoCmd.Maximize to nothing..
is there a way to manual input the size
DoCmd.movesize 1440, 2400, , 2000
For what?
big0
big0
I found thid code in the Archive that TheDbGuy gave me and need a little help:
On the load event of my form. What code do I use to call?
Hope this makes since
big0
Option Compare Database
'CREDITS:
'This modResizeForm module was created by Jamie Czernik 31st March 2000 (jsczernik@hotmail.com)
'The module was updated by Dr. Martin Dumskyj 30th January 2001 (mdumskyj@sghms.ac.UK)
'Module Declarations
Global Const DesignResolutionX = 1024
'CHANGE THE VALUE ABOVE TO THE RESOLUTION YOU DESIGNED YOUR FORM IN!
Global Const WM_HORZRES = 8
Global Const WM_VERTRES = 10
Dim Width As Integer
Dim Factor As Single 'Used as multiplier for current size properties'
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 GetScreenResolution() As String
'returns the height and width
Dim DisplayHeight As Integer
Dim DisplayWidth As Integer
Dim hDesktopWnd As Long
Dim hDCcaps As Long
Dim iRtn As Integer
'API call get current resolution
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
GetScreenResolution = DisplayWidth & "x" & DisplayHeight
Width = DisplayWidth
End Function
Public Sub ReSizeForm(frm As Form)
Dim ctl As Control
'Dim i As Integer
On Error Resume Next
SetFactor 'Call to procedure SetFactor
With frm
.Width = frm.Width * Factor
End With
For Each ctl In frm.Controls
With ctl
.Height = ctl.Height * Factor
.Left = ctl.Left * Factor
.Top = ctl.Top * Factor
.Width = ctl.Width * Factor
.FontSize = .FontSize * Factor
End With
Next ctl
End Sub
Sub SetFactor()
GetScreenResolution 'Call to function GetScreenResolution
Factor = Width / DesignResolutionX
End Sub
big0
I got it to work
thanks
theDBguy
Congratulations! " alt="thumbup.gif" />
HiTechCoach
Glad you got it working! border="0" alt="thumbup.gif" />
urious, How is it working for you?
Kosby
I have been trying to get this to work, but I keep getting a type mismatch error. In the on load event of my form, I have:
eSizeForm(MyForm)
I guess the error is in how I have the argument entered, but I can't figure it out. Any help would be appreciated.
HiTechCoach
What is the DIM statement for MyForm?
How are you setting MyForm?
Based on the sub's parameter:
CODE
Public Sub ReSizeForm(frm As Form)

Assuming that you are running this code from withing the form you should be using something like this:
CODE
Dim MyForm as Form
MyForm = Me  
ReSizeForm(MyForm)

For you could just use this one line:
CODE
ReSizeForm(Me)
Kosby
HiTechCoach,
Thanks for the quick response.
Otried using "Me" as the argument and got the same type mismatch error. It seems like that should work.
HiTechCoach
Did you place all the ReSizeForm code in a Module?
id you name the mode something other than ReSizeForm. Maybe something like this: modReSizeForm or basReSizeForm
Are you using the form's On Load or On Open event to call the ReSizeForm?
Note: I tried ode similar to this once years back but have since stopped trying to resize a form. Just not worth the headaches. In my opinion on the new on wide screen monitor or larger monitor in a high resolution that is just does not look very good.
Kosby
I did place all of the code in a module.
didn't rename it, but I could try if you think it might work.
I am using the on load event.
I won't say that I gave up on it because I think it would be really nice if it worked, but I have manually resized my form to fit a smaller monitor because it needed to be ready for tomorrow.
HiTechCoach
Ah ... making it smaller is normally a problem with the resizers. The resizer really is for making the form larger to fill the screen NOT smaller. I have not seem it work well at all to make it smaller.
If the module name matches the name of a function or sub without the module then Access gets really confused. If you named the module ReSizeForm with a sub in it also named ReSizeForm then IIRC you will need to call the sub in the module like this: ReSizeForm.ReSizeForm(Me)
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.