Resizing forms with the size of the screen

coyote

Registered User.
Local time
Today, 10:31
Joined
Oct 8, 2007
Messages
149
Hi guys
I have developed several applications in ms access 2003 and am xperiencing one setback.
I use a 15" desktop screen and I have a 17" screen laptop.In my applications I have a main form that acts as a background and it remains open and maximized all the time.
When I transfer the applications to the laptop the controls in the main form seem out of position because the screen is bigger. How can I make them move with the size of the screen.
I have tried Jamies Solution but it does not seem to work.
Any help.
Cheers
 
U might wanna copy this code and save it in a module:

Option Compare Database
Option Explicit
Public sMainForm As String
Private Declare Function apiGetSys Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1

Function fGetScreenSize()
Dim strRes As String
strRes = apiGetSys(SM_CXSCREEN) & "x" & apiGetSys(SM_CYSCREEN)
If strRes = "800x600" Then sMainForm = "MyFormSmall"
If strRes = "1024x768" Then sMainForm = "MyFormMedium"
If strRes = "1280x1024" Then sMainForm = "MyFormBig"
End Function

Now u should create 1 MainForm for each expected resolution scenario. To do this open the form on the different screens/resolutions, resize and adjust it till it looks like u want it to, then save it under another name.

Finally u should create a SplashForm which is loaded on app launch and put this code in it:
Private Sub Form_Load()
fGetScreenSize
DoCmd.OpenForm sMainForm
DoCmd.Close AcForm, Me.Name
End Sub

So, as soon as your app loads the SplashForm will call the fGetScreenSize
function and associate the appropriate MainForm version to sMainForm, depending on the screen resolution at hand.

HTH
 

Users who are viewing this thread

Back
Top Bottom