Full Version: Setting Screen Resolution
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
damo_daly
Hi there,

I got a nice piece of code which I found online which sets the screen resolution to 1280x960 when my app opens to allow users to see all of the huge forms,
the code then sets back to 800x600 on close.

Two things Id like to do (if possible) to enhance this:

1. grab the users resolution before I reset it, so I can pass this back in and restore it to what it was,
2. f the Access app does not have focus, is there a way to reset the resolution, so that the users other open apps are not affected?

Im sure the first thing is possible, I just dont know how to get the current resolution so any poiners there would be good,
as for point 2, would this be possible?

EDIT:
Just found code to get the resolution, so point one sorted.

thanks again

DD
yvesdekort
Hi,

What appens if the monitor or the graphics card doesn't support your forced resolution?
damo_daly
Hi

the machines in use in the dept are all of the same standard spec so Ive been assured it will be fine.
I do see your point though, its not a fix I could just roll out anywhere.
yvesdekort
Hi,

Sorry I don't know how to solve your "problem", but I wonder about the need to resize screen resolution.

As a user I wouldn't be happy if a program would change my screenresolution without my permission. (Don't know if you plan to scale down the resolution if the user has a higher one set.)
If the user is still at 800x600, a lot of other applications will also need scroll-bars in order to get everything displayed, so he'll be used to it.

If you do a search on screen resolution here on UA, you'll see this is a much discussed topic.
jleach
Hi,

You'll want the GetSystemMetrics API for obtaining the screen res, but you mentioned you already found that.. be careful what units of measure you're in though, not every pixel size is the same depending on various factors.

As for checking the active window to see if it's the Access window, check out the GetActiveWindow and GetForegroundWindow APIs, and compare to the Application.HWndAccessApp:

CODE
Private Declare Function GetActiveWindow Lib "User32" () As Long
Private Declare Function GetForegroundWindow Lib "User32" () As Long

Public Function IsAccessActive() As Boolean
  Dim l As Long
  l = GetActiveWindow
  If Application.hWndAccessApp = l Then
    IsAccessActive = True
  End If
End Function


There's some subtle differences between the active and foreground windows, and I forget offhand what they are or which you need (so I gave both). Check the MSDN documentation on each and test each in various settings to find out which will work.

For the record, changing the screen resolution so the user can see your forms isn't exactly a standard approach, and maybe not the best ideal, IMHO. I'd look at options for redesigning the forms myself: the above will tell you what the active/foreground window is, but there's no ready event to tell you when that will change. It's not as straightfoward as it seems...

cheers,
damo_daly
Guys, thanks for all this.... time for a re-think now!
jleach
QUOTE
time for a re-think now


I think that'd be a good idea. If you do try the API route you'll find that getting the active window in itself presents more problems that are not so easily fixed. Windows as an OS (and windows as objects) are pretty complicated, you'll be hip deep in sheep dip before you know it!

Cheers,
Gustav
Don't do this. Messing with the user's screen is one of the absolute no-nos in GUI design.

/gustav
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.