ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Screen Resolution (https://www.excelbanter.com/excel-programming/353334-screen-resolution.html)

Jason Zischke

Screen Resolution
 
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

NickHK

Screen Resolution
 
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

"Jason Zischke" wrote in message
...
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




Jason Zischke

Screen Resolution
 
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

"NickHK" wrote:

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

"Jason Zischke" wrote in message
...
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






All times are GMT +1. The time now is 09:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com