Link to home
Start Free TrialLog in
Avatar of TerenceHewett
TerenceHewett

asked on

Screen resolution - changing the Access view when resolution not the same as 1024x768

Hi experts,

Is it possible for Access to open up, check the screen resolution and change the users screen resolution temporarily to 1024x768, and then on close change the resolution back to what the user had before opening up my access db?

The situation is this: I have developed this database in a resolution of 1024x768 so all the forms fill the screen as required.  If the user has a resolution of 1280x1024 and then they open my database, the forms will only take up a smaller area of the screen, and from a GUI perspective, makes the whole database look unprofessional.  Hopefully the above explains my problem, but please let me know if I can offer further guidance to my problem.

Best regards and as usual, thanks.

Terry
Avatar of rockiroads
rockiroads
Flag of United States of America image

Yes, u can but have u thought of users having a screen resolution of 800x600?

Here is sample code that gets the current screen resolution
Simply place in a module


Public Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long

Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1

Sub GetScreenSize()

    Dim x As Long, Y As Long, sYourMessage, iConfirm As Integer
    x = GetSystemMetrics(SM_CXSCREEN)
    Y = GetSystemMetrics(SM_CYSCREEN)
 
    MsgBox "Current screen size is " & x & " x " & Y & vbCrLf
   
End Sub


Now u can use x and y to determine whether screen needs resizing or not

The code I have for changing screen resolutions is this
Screen does go blank for a while though
Again add this code into a module
The function to call is this

ChangeDisplayResolution

Call it passing in your screen res
e.g.
ChangeDisplayResolution 1024, 768


Option Compare Database
Option Explicit

Private Const EWX_REBOOT = 2
Private Const CCDEVICENAME = 32
Private Const CCFORMNAME = 32
Private Const DM_BITSPERPEL = &H40000
Private Const DM_PELSWIDTH = &H80000
Private Const DM_PELSHEIGHT = &H100000
Private Const CDS_UPDATEREGISTRY = &H1
Private Const CDS_TEST = &H4
Private Const DISP_CHANGE_SUCCESSFUL = 0
Private Const DISP_CHANGE_RESTART = 1


Private Type typDevMODE
    dmDeviceName       As String * CCDEVICENAME
    dmSpecVersion      As Integer
    dmDriverVersion    As Integer
    dmSize             As Integer
    dmDriverExtra      As Integer
    dmFields           As Long
    dmOrientation      As Integer
    dmPaperSize        As Integer
    dmPaperLength      As Integer
    dmPaperWidth       As Integer
    dmScale            As Integer
    dmCopies           As Integer
    dmDefaultSource    As Integer
    dmPrintQuality     As Integer
    dmColor            As Integer
    dmDuplex           As Integer
    dmYResolution      As Integer
    dmTTOption         As Integer
    dmCollate          As Integer
    dmFormName         As String * CCFORMNAME
    dmUnusedPadding    As Integer
    dmBitsPerPel       As Integer
    dmPelsWidth        As Long
    dmPelsHeight       As Long
    dmDisplayFlags     As Long
    dmDisplayFrequency As Long
End Type

Private Declare Function EnumDisplaySettings Lib _
  "user32" Alias "EnumDisplaySettingsA" _
  (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, _
  lptypDevMode As Any) As Boolean

Private Declare Function ChangeDisplaySettings Lib _
  "user32" Alias "ChangeDisplaySettingsA" (lptypDevMode As Any, _
  ByVal dwFlags As Long) As Long
 
Private Declare Function ExitWindowsEx Lib _
  "user32" (ByVal uFlags As Long, _
  ByVal dwReserved As Long) As Long
 
Public Function ChangeDisplayResolution(NewWidth As Long, NewHeight As Long) As Boolean

    Dim typDM As typDevMODE
    Dim lRet As Long
    Dim iResp  As Integer
   
    lRet = EnumDisplaySettings(0, 0, typDM)
    If lRet = 0 Then Exit Function
   
    ' Set the new resolution.
    With typDM
        .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
        .dmPelsWidth = NewWidth
        .dmPelsHeight = NewHeight
    End With
   
    lRet = ChangeDisplaySettings(typDM, CDS_UPDATEREGISTRY)
    Select Case lRet
        Case DISP_CHANGE_RESTART
            iResp = MsgBox("You must restart your computer to apply these changes." & vbCrLf & vbCrLf & "Restart now?", vbYesNo + vbInformation, "Screen Resolution Changed")
            If iResp = vbYes Then
                ChangeDisplayResolution = True
            End If
   
        Case DISP_CHANGE_SUCCESSFUL
            ChangeDisplayResolution = True
        Case Else
            ChangeDisplayResolution = False
    End Select

End Function



Hi TerenceHewett,

You mess with MY screen setup and you won't see tomorrow(:-)

Pete
Pete, wot???

If u want to resize forms, have a look at this, see if it helps u http://www.jamiessoftware.tk/resizeform/rf_jump.html
Pete, the fun thing about changing resolutions is to have fun with the users

try changing resolution

ChangeDisplayResolution 768, 1024

instead of

ChangeDisplayResolution 1024, 768

Avatar of LenaWood
LenaWood

I tried to do this once and forced my co-worker into getting a new monitor (then it still didn't work very well).  You have to remember that unless everyone that will be using this database has a fairly new monitor they may not be able to have the resolution set like you have it.  I know we have some older monitors here (ok I work for a company that has a contract with the government and we get new technology once it isn't so new - just got Office 2000) and setting the resolution like you want to just wouldn't work.  I had to set my monitor to the resolution that was used the most (or sneak in and change their resolution without them knowing it haha).

Good luck,
Lena
Avatar of TerenceHewett

ASKER

Hi all,

Rocki, I have tried your code, and it works very well, except I need the code to recognise the users screen resolution at start up, change to 1024x768 and then change back to whatever the users screen resolution was prior to starting up my db.  Is this possible?

Regards,

Terry

PS: Thank you for all posts.  I have taken on board your comments.

I posted that code for you

look at the function GetScreenSize, it returns the current screen res
u then save those values somewhere, then revert to them when u need to
Hi all, thanks for the posts.  Rocki, I have not forgotten this post.  As usual, I have been assigned to a number of different database projects and currently trying to juggle everything.  I think I had forgotten to add the code from the previous post with code in it with the GetScreenSize..I will try this asap.

Thanks for all your patience.

Regards,
Terry
No worries, take your time
Hi all,

Rock, all is working except I cannot get the GetScreenSize to work in the way that I would like.  At the moment, I have all the code you gave me in a couple of modules. I have a screen resolution of 1024x768 which is also the best view for my users, but some users might have 1152x864 and others some other resolution.  The GetScreenSize does do its job in the fact that it puts a pop up on screen advising the current screen resolution, but I cannot find a way to store that information, change the resolution to 1024x768 and then revert the recorded screen resolution using GetScreenSize.  I am not seeing the wood through the trees on this, so apologise, but could do with some help here if its possible?

Very best wishes,


Terry  
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Rock, thank you for the above solution. Lena and Peter, thank you also for your posts.  Very much appreciated.

Regards,
Terry