+ Reply to Thread
Results 1 to 7 of 7

Screen resolutions and resizing forms

  1. #1
    Ken Soenen
    Guest

    Screen resolutions and resizing forms


    Is there some software technique that could change the size of your Forms
    when you run the Forms with different screen resolutions?
    For example: I keep my screen at 1280x1024. When I run the form on say
    1024x768, the whole form becomes unnecessarily large and may not even fit on
    the screen.
    At a minimum, is there some system item that indicates the current screen
    resolution, that I could query, and then manually(at Form activation) change
    the Form and control sizes?

    Thanks



  2. #2
    Ron de Bruin
    Guest

    Re: Screen resolutions and resizing forms

    Hi Ken

    You can use this in a module

    Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

    Function DisplayVideoResolution() As String
    DisplayVideoResolution = GetSystemMetrics32(0) & " x " & GetSystemMetrics32(1)
    End Function

    Then in your code you can use this

    If DisplayVideoResolution = "1024 x 768" Then ......................


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Ken Soenen" <[email protected]> wrote in message news:[email protected]...
    >
    > Is there some software technique that could change the size of your Forms when you run the Forms with different screen
    > resolutions?
    > For example: I keep my screen at 1280x1024. When I run the form on say 1024x768, the whole form becomes unnecessarily large and
    > may not even fit on the screen.
    > At a minimum, is there some system item that indicates the current screen resolution, that I could query, and then manually(at
    > Form activation) change the Form and control sizes?
    >
    > Thanks
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: Screen resolutions and resizing forms

    http://support.microsoft.com/?id=148395
    ACC: How to Determine the Current Screen Resolution (95/97)


    '*****************************************************************
    ' DECLARATIONS SECTION
    '*****************************************************************
    Option Explicit
    Type RECT
    x1 As Long
    y1 As Long
    x2 As Long
    y2 As Long
    End Type
    ' NOTE: The following declare statements are case sensitive.
    Declare Function GetDesktopWindow Lib "User32" () As Long
    Declare Function GetWindowRect Lib "User32" _
    (ByVal hWnd As Long, rectangle As RECT) As Long
    '*****************************************************************
    ' FUNCTION: GetScreenResolution() ' ' PURPOSE:
    ' To determine the current screen size or resolution. '
    ' RETURN:
    ' The current screen resolution. Typically one of the following:
    ' 640 x 480 ' 800 x 600 ' 1024 x 768 '
    '*****************************************************************
    Function GetScreenResolution() As String
    Dim R As RECT
    Dim hWnd As Long
    Dim RetVal As Long
    hWnd = GetDesktopWindow()
    RetVal = GetWindowRect(hWnd, R)
    GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)
    End Function


    ==============
    Posted by Laurent Longre, Programming 06/10/99

    Declare Function GetDeviceCaps Lib "Gdi32" (ByVal hdc As Long, _
    ByVal nIndex As Long) As Long
    Declare Function GetDC Lib "User32" (ByVal hWnd As Long) As Long
    Declare Function ReleaseDC Lib "User32" (ByVal hWnd As Long, _
    ByVal hdc As Long) As Long

    Sub Test()
    Dim DC As Long
    DC = GetDC(0)
    MsgBox "Resolution : " & GetDeviceCaps(DC, 8) _
    & " * " & GetDeviceCaps(DC, 10) & " pixels"
    ReleaseDC 0, DC
    End Sub
    ==================

    Option Explicit

    Private Declare Function GetSystemMetrics _
    Lib "user32" (ByVal nIndex As _
    Long) As Long

    Private Const SM_CXSCREEN = 0
    Private Const SM_CYSCREEN = 1

    Public Function GSR() As String
    GSR = CStr(GetSystemMetrics(SM_CXSCREEN)) _
    & "x" & CStr(GetSystemMetrics _
    (SM_CYSCREEN))
    End Function
    ===================

    the userform has a Zoom property. You can see if that will work for you.
    If not, you may have to work with each control on the form, or have separate
    copies of your userform for different resolutions.

    --
    Regards,
    Tom Ogilvy

    "Ken Soenen" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Is there some software technique that could change the size of your Forms
    > when you run the Forms with different screen resolutions?
    > For example: I keep my screen at 1280x1024. When I run the form on say
    > 1024x768, the whole form becomes unnecessarily large and may not even fit

    on
    > the screen.
    > At a minimum, is there some system item that indicates the current screen
    > resolution, that I could query, and then manually(at Form activation)

    change
    > the Form and control sizes?
    >
    > Thanks
    >
    >




  4. #4
    STEVE BELL
    Guest

    Re: Screen resolutions and resizing forms

    You might consider sizing the form to the screen size...

    Here's some code Ron posted a long time ago...

    'Fill the Screen
    Private Sub UserForm_Initialize()
    With Application
    Me.Top = .Top
    Me.Left = .Left
    Me.Height = .Hight
    Me.Width = .Width
    End With
    End Sub

    --
    steveB

    Remove "AYN" from email to respond
    "Ken Soenen" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Is there some software technique that could change the size of your Forms
    > when you run the Forms with different screen resolutions?
    > For example: I keep my screen at 1280x1024. When I run the form on say
    > 1024x768, the whole form becomes unnecessarily large and may not even fit
    > on the screen.
    > At a minimum, is there some system item that indicates the current screen
    > resolution, that I could query, and then manually(at Form activation)
    > change the Form and control sizes?
    >
    > Thanks
    >




  5. #5
    Tom Ogilvy
    Guest

    Re: Screen resolutions and resizing forms

    That would leave controls along the edges invisible and off the form if he
    develops on 1280 by 1040 then displays it on 800 x 600 for example. then
    if he gathered all the controls in the upper left corner to protect against
    that, it would just look stupid in 1280 by 1040 <g>

    --
    Regards,
    Tom Ogilvy

    "STEVE BELL" <[email protected]> wrote in message
    news:Mcknf.9504$Ea6.5376@trnddc08...
    > You might consider sizing the form to the screen size...
    >
    > Here's some code Ron posted a long time ago...
    >
    > 'Fill the Screen
    > Private Sub UserForm_Initialize()
    > With Application
    > Me.Top = .Top
    > Me.Left = .Left
    > Me.Height = .Hight
    > Me.Width = .Width
    > End With
    > End Sub
    >
    > --
    > steveB
    >
    > Remove "AYN" from email to respond
    > "Ken Soenen" <[email protected]> wrote in message
    > news:[email protected]...
    > >
    > > Is there some software technique that could change the size of your

    Forms
    > > when you run the Forms with different screen resolutions?
    > > For example: I keep my screen at 1280x1024. When I run the form on say
    > > 1024x768, the whole form becomes unnecessarily large and may not even

    fit
    > > on the screen.
    > > At a minimum, is there some system item that indicates the current

    screen
    > > resolution, that I could query, and then manually(at Form activation)
    > > change the Form and control sizes?
    > >
    > > Thanks
    > >

    >
    >




  6. #6
    STEVE BELL
    Guest

    Re: Screen resolutions and resizing forms

    Thanks Tom,

    Didn't realize this problem...

    --
    steveB

    Remove "AYN" from email to respond
    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > That would leave controls along the edges invisible and off the form if he
    > develops on 1280 by 1040 then displays it on 800 x 600 for example. then
    > if he gathered all the controls in the upper left corner to protect
    > against
    > that, it would just look stupid in 1280 by 1040 <g>
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "STEVE BELL" <[email protected]> wrote in message
    > news:Mcknf.9504$Ea6.5376@trnddc08...
    >> You might consider sizing the form to the screen size...
    >>
    >> Here's some code Ron posted a long time ago...
    >>
    >> 'Fill the Screen
    >> Private Sub UserForm_Initialize()
    >> With Application
    >> Me.Top = .Top
    >> Me.Left = .Left
    >> Me.Height = .Hight
    >> Me.Width = .Width
    >> End With
    >> End Sub
    >>
    >> --
    >> steveB
    >>
    >> Remove "AYN" from email to respond
    >> "Ken Soenen" <[email protected]> wrote in message
    >> news:[email protected]...
    >> >
    >> > Is there some software technique that could change the size of your

    > Forms
    >> > when you run the Forms with different screen resolutions?
    >> > For example: I keep my screen at 1280x1024. When I run the form on say
    >> > 1024x768, the whole form becomes unnecessarily large and may not even

    > fit
    >> > on the screen.
    >> > At a minimum, is there some system item that indicates the current

    > screen
    >> > resolution, that I could query, and then manually(at Form activation)
    >> > change the Form and control sizes?
    >> >
    >> > Thanks
    >> >

    >>
    >>

    >
    >




  7. #7
    Tom Ogilvy
    Guest

    Re: Screen resolutions and resizing forms

    It isn't a problem - it is a feature. That is how you would implement a
    Show Details button.

    --
    Regards,
    Tom Ogilvy




    "STEVE BELL" <[email protected]> wrote in message
    news:gAknf.9714$Ea6.4496@trnddc08...
    > Thanks Tom,
    >
    > Didn't realize this problem...
    >
    > --
    > steveB
    >
    > Remove "AYN" from email to respond
    > "Tom Ogilvy" <[email protected]> wrote in message
    > news:[email protected]...
    > > That would leave controls along the edges invisible and off the form if

    he
    > > develops on 1280 by 1040 then displays it on 800 x 600 for example.

    then
    > > if he gathered all the controls in the upper left corner to protect
    > > against
    > > that, it would just look stupid in 1280 by 1040 <g>
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "STEVE BELL" <[email protected]> wrote in message
    > > news:Mcknf.9504$Ea6.5376@trnddc08...
    > >> You might consider sizing the form to the screen size...
    > >>
    > >> Here's some code Ron posted a long time ago...
    > >>
    > >> 'Fill the Screen
    > >> Private Sub UserForm_Initialize()
    > >> With Application
    > >> Me.Top = .Top
    > >> Me.Left = .Left
    > >> Me.Height = .Hight
    > >> Me.Width = .Width
    > >> End With
    > >> End Sub
    > >>
    > >> --
    > >> steveB
    > >>
    > >> Remove "AYN" from email to respond
    > >> "Ken Soenen" <[email protected]> wrote in message
    > >> news:[email protected]...
    > >> >
    > >> > Is there some software technique that could change the size of your

    > > Forms
    > >> > when you run the Forms with different screen resolutions?
    > >> > For example: I keep my screen at 1280x1024. When I run the form on

    say
    > >> > 1024x768, the whole form becomes unnecessarily large and may not even

    > > fit
    > >> > on the screen.
    > >> > At a minimum, is there some system item that indicates the current

    > > screen
    > >> > resolution, that I could query, and then manually(at Form activation)
    > >> > change the Form and control sizes?
    > >> >
    > >> > Thanks
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >




+ 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