change screenresolution

sven2

Registered User.
Local time
Today, 17:52
Joined
Apr 28, 2007
Messages
297
Hi,

because there are different users on different computers and screenresolutions I want to do the following with my database:

1) while opening the database the screenresolution should be saved as a parameter
2) after that the screenresolution should be changed in 1084 X 1024
3) when the database is quit the screenresolution should be put back as it was at the beginning (parameter)

I have found a piece of code on the net and it works ... but if I want to build it in my database it is not working. Secondly I am wondering if it is not possible to to this on a more easier way?

Best regards,
Sven.
 

Attachments

RE: Changing Screenresolution

Hey Sven2

I tried to get the code to work in my database as well but have been unable to. I to would really like to get this to work in my database. I am getting a run time error 3270 and have been unable to locate a reason. If anyone knows a fix or why it would work in the sample but not when it is moved.


Thanks
 
IMHO, you would be much better off to retrieve the native screen resolution and reconfigure your forms on the fly rather than muck about with the settings on the user's PC. User's don't always have administrative rights and from experience, the only thing you can guarantee you have control over is your own application. :D
 
Here's how to get the system's screen resolution:

Code:
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Public Function GetScreenResolution() As String
    
    [COLOR="green"]'returns the screen resolution
    'GetSystemMetrics(0) is the Width
    'GetSystemMetrics(1) is the Height[/COLOR]
    GetScreenResolution = GetSystemMetrics(0) & "x" & GetSystemMetrics(1)

End Function

Note that the above code needs to be in its own module. You can't make user-defined functions that use API calls in form modules.

Also, he is right in that the best method is to resize your forms on the fly as some users will not have the ability to change their screen resolutions, some will freak out if their resolution changes, some will be confused if they alt-tab out and everything looks different, etc. It's possible to set the screen resolution in Access, but highly unrecomended. If you'd rather not dynamically change your form sizes, then you can check for a minimum resolution and then either tell the user that they need a resolution of X by Y or that they will have to scroll around your application. It would look like this:

Code:
Sub CheckRes()

    If GetSystemMetrics(0) < 1024 And GetSystemMetrics(1) < 768 then
        MsgBox "This application is designed to run at a resolution 1024x768 or better.  Please contact your system administrator if you need help adjusting your resolution."
        Application.Quit
    End If

End Sub

The above will check to see that the user is at least at 1024x768. If not, it gives them a message to change their resolution and closes the application. Keep in mind that some laptops use strange default resolutions (1080x720 comes to mind) as do wide screen monitors, so when picking a minimum resolution, take that into consideration.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom