Screen Resolution

J

Jason Zischke

Hi All,

I loaded my program onto another computer this morning and it had problems
gettingthe screen resolution to size my forms. What is the problem here and
how can I fix this show it doesn't happen, below is my code.

Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Private Const SM_CYCAPTION = 4
Private Const SM_CXBORDER = 5
Private Const SM_CYBORDER = 6
Private Const SM_CXFULLSCREEN = 16
Private Const SM_CYFULLSCREEN = 17
Private Const SM_CXVIRTUALSCREEN As Long = 78
Private Const SM_CMONITORS As Long = 80
Private Declare Function GetSystemMetrics32 Lib "user32" Alias _
"GetSystemMetrics" (ByVal nIndex As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As
Long) As Long
Dim lWidth As Long, lHeight As Long
Sub getScreenResolution(lWidth As Long, lHeight As Long)
lWidth = GetSystemMetrics(SM_CXSCREEN)
lHeight = GetSystemMetrics(SM_CYSCREEN)
End Sub
Private Sub UserForm_Activate()
getScreenResolution lWidth, lHeight
frmSTARTUP.Height = lHeight * 0.75
frmSTARTUP.Width = lWidth * 0.75
frmSTARTUP.Image7.Top = (lHeight * 0.75) - (48 * 1.5)
frmSTARTUP.Image5.Top = (lHeight * 0.75) - (42 * 1.5)
frmSTARTUP.Image5.Left = (lWidth * 0.75) - (90 * 1.5)
frmSTARTUP.Image3.Left = (lWidth * 0.17)
frmSTARTUP.Image3.Height = (lHeight * 0.445)
frmSTARTUP.Image3.Width = (lWidth * 0.565)
frmSTARTUP.Frame5.Left = (lWidth * 0.01)
frmSTARTUP.Frame5.Height = (lHeight * 0.44)
frmSTARTUP.Frame5.Width = (lWidth * 0.15)
frmSTARTUP.Label30.Top = (lHeight * 0.725) - (48 * 1.5)
frmSTARTUP.Show
End Sub

Thanks in Advance

Jason
 
N

NickHK

Jason,
It depends on what you mean by "it had problems gettingthe screen
resolution".
If you checked the value of lWidth and lHeight, you would know if these call
succeeded.

Also, API dimensions usually work in pixels, but AFAIK userform dimensions
are not (points ?).
So you would need to convert using PointsToScreenPixelsX etc.

NickHK
 
J

Jason Zischke

NickHK,

The Values came up as Zero for the value while on the computer I use the
values were right and the form fitted.

Jason
 

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