Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screen Resolution 2

Status
Not open for further replies.

fileman1

Technical User
Feb 7, 2013
152
GB
I am having problems not being able to optimise a database for a user having a laptop with a connected larger monitor. When they slide the application from one screen to the other they have problems.

I am trying to make a blank form that will have command buttons on to set height/width/top/left settings which will display the parameters which I can then base form sizes with. Ideally I wanted an blank initial form which will hide their desktop, however setting form on open to docmd.maximize gives them their first problem, parts of it overfill to the other screen.

So I started to make the first form the blanking one, however how do I get rid of the Access furniture (ie ribbon etc) I went into Options and checked them all out but the Access application still dominates the screen even after making an accde version. Any suggestions? Thanks
 
I did a test form for the user to try and get a compromise screen size for a form (laptop and screen) but they came back with coordinates for each screen.

Is there a way to make a blank base form to hide all Access bits ie ribbon etc, that would be compatable between screens when a user slid the app from screen to screen. I'm just trying to blank out everything to make the application look as though it's a real .exe program, not just an Access application.
 
Many thanks, I will try it out tomorrow and come back on how I did.
 
The easiest way to get rid of all the Accessy bits like the ribbon is simply to run the database in the Access Runtime rather than the full access. You can do this by changing the file extension to ".accdr" instead of ".accdb", by adding "/runtime" to the link in a shortcut that runs the database, or by using the Access runtime version (which is free!) instead of full Access.
 
Thanks both. The code in the link works for Access 2010 okay.
I am still playing around trying to get a compromise form size/position for someone using a Laptop connected to monitor. I thought I was getting near, but putting controls on the form seems to affect form size, does not always seem to be what you see is you get. Never mind, weekend is here!!
 
There is an API that will give you screen resolution...

Note the first 2 contstants for determining the pixel width and height of the screen.

You could then detect the screen resolution and then either programmatically adapt the form or open a different form, essentially another version. Both are a pain to get working as programmatically manipulating the screen is done in twips and the conversion is messy at best. Alternately, any changes you make to a form have to be made to the others.

Code:
Option Compare Database
Option Explicit
'Tech Net article
'ACC: How to Use the GetSystemMetrics() API Call
'PSS ID Number: Q88922

     Public Const SM_CXSCREEN = 0        ' Width of screen
     Public Const SM_CYSCREEN = 1        ' Height of screen
     Public Const SM_CXFULLSCREEN = 16   ' Width of window client area
     Public Const SM_CYFULLSCREEN = 17   ' Height of window client area
     Public Const SM_CYMENU = 15         ' Height of menu
     Public Const SM_CYCAPTION = 4       ' Height of caption or title
     Public Const SM_CXFRAME = 32        ' Width of window frame
     Public Const SM_CYFRAME = 33        ' Height of window frame
     Public Const SM_CXHSCROLL = 21      ' Width of arrow bitmap on
                                  '  horizontal scroll bar
     Public Const SM_CYHSCROLL = 3       ' Height of arrow bitmap on
                                  '  horizontal scroll bar
     Public Const SM_CXVSCROLL = 2       ' Width of arrow bitmap on
                                  '  vertical scroll bar
     Public Const SM_CYVSCROLL = 20      ' Height of arrow bitmap on
                                  '  vertical scroll bar
     Public Const SM_CXSIZE = 30         ' Width of bitmaps in title bar
     Public Const SM_CYSIZE = 31         ' Height of bitmaps in title bar
     Public Const SM_CXCURSOR = 13       ' Width of cursor
     Public Const SM_CYCURSOR = 14       ' Height of cursor
     Public Const SM_CXBORDER = 5        ' Width of window frame that cannot
                                  '  be sized
     Public Const SM_CYBORDER = 6        ' Height of window frame that cannot
                                  '  be sized
     Public Const SM_CXDOUBLECLICK = 36  ' Width of rectangle around the
                                  '  location of the first click. The
                                  '  second click must occur in the
                                  '  same rectangular location.
     Public Const SM_CYDOUBLECLICK = 37  ' Height of rectangle around the
                                  '  location of the first click. The
                                  '  second click must occur in the
                                  '  same rectangular location.
     Public Const SM_CXDLGFRAME = 7      ' Width of dialog frame window
     Public Const SM_CYDLGFRAME = 8      ' Height of dialog frame window
     Public Const SM_CXICON = 11         ' Width of icon
     Public Const SM_CYICON = 12         ' Height of icon
     Public Const SM_CXICONSPACING = 38  ' Width of rectangles the system
                                  ' uses to position tiled icons
     Public Const SM_CYICONSPACING = 39  ' Height of rectangles the system
                                  ' uses to position tiled icons
     Public Const SM_CXMIN = 28          ' Minimum width of window
     Public Const SM_CYMIN = 29          ' Minimum height of window
     Public Const SM_CXMINTRACK = 34     ' Minimum tracking width of window
     Public Const SM_CYMINTRACK = 35     ' Minimum tracking height of window
     Public Const SM_CXHTHUMB = 10       ' Width of scroll box (thumb) on
                                  '  horizontal scroll bar
     Public Const SM_CYVTHUMB = 9        ' Width of scroll box (thumb) on
                                  '  vertical scroll bar
     Public Const SM_DBCSENABLED = 42    ' Returns a non-zero if the current
                                  '  Windows version uses double-byte
                                  '  characters, otherwise returns
                                  '  zero
     Public Const SM_DEBUG = 22          ' Returns non-zero if the Windows
                                  '  version is a debugging version
     Public Const SM_MENUDROPALIGNMENT = 40
                                  ' Alignment of pop-up menus. If zero,
                                  '  left side is aligned with
                                  '  corresponding left side of menu-
                                  '  bar item. If non-zero, left side
                                  '  is aligned with right side of
                                  '  corresponding menu bar item
     Public Const SM_MOUSEPRESENT = 19   ' Non-zero if mouse hardware is
                                  '  installed
     Public Const SM_PENWINDOWS = 41     ' Handle of Pen Windows dynamic link
                                  '  library if Pen Windows is
                                  '  installed
     Public Const SM_SWAPBUTTON = 23     ' Non-zero if the left and right
                                  ' mouse buttons are swapped

Declare Function GetSystemMetrics& Lib "User32" (ByVal nIndex&)
 
And another way to hide the ribbon...

Code:
docmd.ShowToolbar "Ribbon", acToolbarNo
 
>GetSystemMetrics

Unfortunately only gets the resolution of the primary display. The OP is experiencing a problem due to having multiple displays

To get the displayable rectangle of a specific monitor you need to either enumerate the monitors in use (EnumDisplayMonitors) or determine it from the displayed window (e.g. MonitorFromWindow or MonitorFromRect) and then query the specific monitor in question (GetMonitorInfo)
 
Excellent point strongm.... I had not noticed that in my handful of uses but tested it true on Win7.

That probably explains why so many programs misbehave (or at least used to) when moved from the primary screen.
 
Many thanks. I found some code that identified the resolution of whichever screen was viewing a form. I am putting a command button on the form to identify the screen/resolution and then use appropriate Movesize values for my form.
This is the basis of my my code:

Code:
Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1

Code:
Sub VerifyScreenResolution(Optional Dummy As Integer)
   
 Dim x  As Long
    Dim y  As Long
    Dim MyMessage As String
    Dim MyResponse As VbMsgBoxResult
     
    x = GetSystemMetrics(SM_CXSCREEN)
    y = GetSystemMetrics(SM_CYSCREEN)
       
    MsgBox "Your current screen resolution is " & x & " X " & y & vbCrLf & ""
        
End Sub

Code:
Private Sub Command18_Click()
Call VerifyScreenResolution
End Sub

Hope it's of interest
 
Sorry, I did. However I send a form to somebody who moved the form from one screen to another, clicking the button it gave the two resolutions wherever the form was sent to of two screens. They were able to email me back the two resolutions?
 
I tested it not working WIN7 32 bit Access 2007, ATI RAdeon 4250 Graphics. I suspect strongm saying it doesn't work is the expected behavior according to the API definition. It sounds like either the user reported to you the resolution of the two screens not using the form or something about that setup is set to intercept the GetsystemMetrics call (I'd guess display driver but that seems outside the scope of what it should do).
 
Thanks. I asked for my form to be retested, even though the user insisted it worked. If only after all the generations of Access these things were taken care of now. Guess if it's dodgy I will have to make different versions of the forms. Trouble is I cannot get the resolutions they have on my two PC'S to see whats happening.
Thanks for your help
 
The issue is with that particular API call... strongm pointed to a few others that may prove more useful...

strongm said:
To get the displayable rectangle of a specific monitor you need to either enumerate the monitors in use (EnumDisplayMonitors) or determine it from the displayed window (e.g. MonitorFromWindow or MonitorFromRect) and then query the specific monitor in question (GetMonitorInfo)

But it would be great if Access had some sort of form scaling option built in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top