Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get screen resolution StevenS Excel Programming 3 November 12th 05 01:01 PM
Screen Resolution Ronbo Excel Programming 2 January 17th 05 08:45 PM
Screen Resolution Sheldon Excel Programming 1 November 2nd 04 05:52 PM
Screen resolution Arkimediz Excel Programming 3 April 1st 04 05:23 PM
Can the screen resolution be changed within VBA? DennisE Excel Programming 1 March 7th 04 12:16 AM


All times are GMT +1. The time now is 05:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"