+ Reply to Thread
Results 1 to 3 of 3

Screen Resolution

  1. #1
    Jason Zischke
    Guest

    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. #2
    NickHK
    Guest

    Re: 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" <JasonZischke@discussions.microsoft.com> wrote in message
    news:57299EE2-D9E3-4B72-940F-0C5CE39297E7@microsoft.com...
    > 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. #3
    Jason Zischke
    Guest

    Re: 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" <JasonZischke@discussions.microsoft.com> wrote in message
    > news:57299EE2-D9E3-4B72-940F-0C5CE39297E7@microsoft.com...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1