Message 1 of 4
Screensize in points

Not applicable
03-03-2005
03:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to keep my form centered vertically on the screen when it gets
resized.
VB provides the Screen.Height function but VBA apparently doesn't.
I can use the GetSystemMetrics(SM_CYSCREEN) to get the screen height in
pixels but VBA sizes appear to be in points.
Is there a conversion factor for points to pixels?
So far, I've stretched the window to its maximum height and read that value
to set the maximum height, but that's sort of a dirty hack.
Any ideas?
Private Sub UserForm_Resize()
'Guess of the screen height by stretching the window as large as
'it could go yielded 777 - would be better to use the GetSystemMetrics
'but I don't know the conversion from points to pixels.
hgt = Me.Height
scrnhgt = 777 ' GetSystemMetrics(SM_CYSCREEN)
Me.top = (scrnhgt - hgt) / 2
End Sub