Another Code ?

S

Scientific

Hello all,

I have a Function that gets the screen resolution and I want to use it to
open two forms depending on the screen resolution. The code needs to run
before Access opens any forms, then i need a way to open Form1 if resolution
is 800x600 and Form2 if resolution is 1024x768. How do I set this up? All
help is greatly appreciated!

Code Follows:

Option Explicit

Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type

Declare Function GetDesktopWindow Lib "User32" () As Long
Declare Function GetWindowRect Lib "User32" _
(ByVal hWnd As Long, rectangle As RECT) As Long

'*********************************************
' FUNCTION: GetScreenResolution()
'
' PURPOSE:
' To determine the current screen size or resolution.
'
' RETURN:
' The current screen resolution. Typically one of the following:
' 640 x 480
' 800 x 600
' 1024 x 768
'
'**********************************************
Function GetScreenResolution() As String

Dim R As RECT
Dim hWnd As Long
Dim RetVal As Long

hWnd = GetDesktopWindow()
RetVal = GetWindowRect(hWnd, R)
GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)

End Function
 
B

Beetle

In, for example, the Click event of a command button on perhaps some
type of splash screen or initial popup form, you sould use code like;

Select Case GetScreenResolution
Case "800X600"
DoCmd.OpenForm "Form1"
Case "1024X768"
DoCmd.OpenForm "Form2"
End Select
 
P

pddxxx

It looks like you're going to have to maintain two copies of each of
your forms. As an alternative, you may want to consider scaling your
forms for each screen resolution.

There are third-party form scaling solutions available that might
help:

A shareware version of a form rescaling module I wrote called
ShrinkerStretcher is available at this web site: http://www.peterssoftware.com/ss.htm

There's a form resizer at http://www.jamiessoftware.tk/resizeform/rf_jump.html
..

Another one: http://sourceforge.net/projects/modscaleform

The Access Developer's Handbook has form resizing code included:
http://www.amazon.com/exec/obidos/ISBN=0782119417/107-8064361-7403703

Hope this helps,

Peter De Baets
Peter's Software - Microsoft Access Tools for Developers
http://www.peterssoftware.com
 
S

Scientific

Beetle, pddxxx,

Thanks a million for your replies. You have solved my question and I now
know how to proceed from here. Beetle you made this easier than I thought
possible.

-S
 

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

Top