Using different format depending on screen

  • Thread starter Thread starter Sophie
  • Start date Start date
S

Sophie

greetings

I have an access db that I use at home on a PC with a large screen and on
the road using a laptop. In each of my many forms, the Form_Open event has a
line like...

DoCmd.MoveSize 150, 6000, 6750, 4770

that works well for the screen in question. I use one set of numbers on my
PC and another set on the laptop. I'd like the program to somehow recognize
which computer I'm using so that I can use If...Else If... to set the
correct values for each machine.

I'm really not sure how to do this. Any clues would be appreciated.
 
Sophie said:
greetings

I have an access db that I use at home on a PC with a large screen and on
the road using a laptop. In each of my many forms, the Form_Open event
has a
line like...

DoCmd.MoveSize 150, 6000, 6750, 4770

that works well for the screen in question. I use one set of numbers on
my
PC and another set on the laptop. I'd like the program to somehow
recognize
which computer I'm using so that I can use If...Else If... to set the
correct values for each machine.

I'm really not sure how to do this. Any clues would be appreciated.

How about retrieving the screen dimensions instead of identifying the PC? If
this sounds like a plan to you, then paste the following into a new standard
module:

''' CODE START '''
Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long

Public Enum srMetric
srpixels = 1
srtwips = 2
End Enum

Private Const SM_CXSCREEN = 0 'X Size of screen
Private Const SM_CYSCREEN = 1 'Y Size of Screen

Public Function ScreenWidth(Optional Metric As srMetric = srtwips) As Long
t& = GetSystemMetrics(SM_CXSCREEN)
ScreenWidth = IIf(Metric = srpixels, t, t \ 15)
End Function

Public Function ScreenHeight(Optional Metric As srMetric = srtwips) As Long
t& = GetSystemMetrics(SM_CYSCREEN)
ScreenHeight = IIf(Metric = srpixels, t, t \ 15)
End Function
''' CODE END '''

Usage:

lngWidth = ScreenWidth()
lngHeight = ScreenHeight()

will give you the dimensions in twips (which is what you're using in your
MoveSize call).
 
Stuart - Thanks for your response. It has taken me a while to understand
this level of code, but I think I've got it now. This is exactly what I
needed.

By the way, I think that the 't \ 15' needs to be replaced by 't * 15' in
two places.
 
Sophie said:
Stuart - Thanks for your response. It has taken me a while to understand
this level of code, but I think I've got it now. This is exactly what I
needed.

By the way, I think that the 't \ 15' needs to be replaced by 't * 15' in
two places.
<SNIP>

Glad you found it to be of use, and yes you're right about the t\15 thing. I
cobbled the code together from a much larger module and in the process
introduced a typo (will I never learn :)

FYI the 'Public Enum srMetric' bit is just defining a couple of consts. The
reason it's an Enum is so that the options are displayed as you type the
function call.

The GetSystemMetrics function is provided by windows to provide various
sizes, like border widths, titlebar heights, screen size - etc.

HTH
 
Back
Top