Adjusting form size to screen resolution

  • Thread starter Miha Abrahamsberg
  • Start date

Miha Abrahamsberg


I use:

Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As
Public Function GetScreenResolution() As String
'returns the screen resolution
'GetSystemMetrics (0) is the Width
'GetSystemMetrics (1) is the Height
GetScreenResolution = GetSystemMetrics(0) & "x" & GetSystemMetrics(1)
End Function

to get the user's screen resolution and I adjust certain forms' (size, font)
according to it.

But I have a problem where some of "my end users" use 2 screens (multiple
desktops) and one screen uses higher resolution then the other.

In such cases the function GetScreenResolution returns the default's screen

How should I adjust the code to be able to get both screens resolution


Allen Browne

Someone may be able to suggest an API call that works with particular
versions of Windows that handle multiple screens and gives you the
resolution for each screen.

You would also need to know which screen your application is on, and have
some kind of event handler that notifies you when the user switches it to a
different screen.

One of my 2 screens is in portrait mode. I find that brilliant for
developing: the main Access app under development displays on the landscape
screen, and the VBA IDE goes on the portrait screen showing > 100 lines of
code at once. This kind of thing:
So you would need to adapt your application to that.

Saw a setup with 4 monitors last week. That should give you some fun.

Presumably you also need to be notified if the user restores the app into a
window that is not using the whole screen, or changes the size of the
application window. And you have to handle any pop-up screens that open
outside the main Access window. And handle any changes Microsoft may make in
future (like they did in A2007.)

In the end, I seriously question whether this approach is a good one.
Personally, I hate applications that believe I bought a large screen just so
they could take up the whole thing. IMHO, you are better off to specify a
minimum resolution for running your app (e.g. 1024 x 768), and build it for

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question