Making an application the same size in all resolutions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vdraceil
    New Member
    • Jul 2007
    • 236

    Making an application the same size in all resolutions

    Hi everyone, i made an application with vb6 in my pc,but when i transferred it to a laptop,the relative positions of controls has changed..it seems it has something to do with the resolution..got any solution?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You ned to resize the form as per monitor resolution.

    Comment

    • vdraceil
      New Member
      • Jul 2007
      • 236

      #3
      Originally posted by debasisdas
      You ned to resize the form as per monitor resolution.
      how do i do that?pls help..

      Comment

      • vdraceil
        New Member
        • Jul 2007
        • 236

        #4
        I know how to change the resolution of the system as a whole..but i dont know how to make the form look same in all kind of resolutions..-i mean we should not change the computer's resolution only because our form has to run properly.. Got any ideas?

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          findout the resolution of the monitor and resize the form and other controls accordingly.

          Comment

          • vdraceil
            New Member
            • Jul 2007
            • 236

            #6
            Originally posted by debasisdas
            findout the resolution of the monitor and resize the form and other controls accordingly.
            thanks for ur reply..
            after finding out the resolution of the monitor,what do i do?
            how do i size my form accordingly?i mean what size should i hav for one resolution and what for some other resolution?
            how do i proceed??
            an example would help..

            Comment

            • ubentook
              New Member
              • Dec 2007
              • 58

              #7
              This code from Jim Cone worked for me...

              Declare Function GetSystemMetric s Lib "user32" (ByVal nIndex As Long) As Long

              Sub ResizeForm_R1()
              ' Adjusts userform size to compensate for screen resolution changes.
              ' Calls function GetSR
              ' Jim Cone - San Francisco, USA - Dec 2006
              Dim varSize As Variant
              Dim RatioX As Single
              Dim RatioY As Single
              Dim ActualX As Long
              Dim ActualY As Long

              'Screen resolution in development environment.
              'Adjust as necessary <<<
              Const BaseX As Long = 800
              Const BaseY As Long = 600

              'Call function to get actual screen resolution
              varSize = GetSR
              ActualX = varSize(0)
              ActualY = varSize(1)

              'Determine ratio of actual screen resolution to
              'the original or base resolution.
              RatioX = ActualX / BaseX
              RatioY = ActualY / BaseY

              'Adjust userform magnification and size.
              UserForm1.Zoom = (100 * ((RatioX + RatioY) / 2))
              UserForm1.Width = UserForm1.Width * RatioX
              UserForm1.Heigh t = UserForm1.Heigh t * RatioY
              UserForm1.Show
              Unload UserForm1
              Set UserForm1 = Nothing
              End Sub

              '---------------------------------
              Public Function GetSR() As Variant
              ' x and y
              GetSR = Array(GetSystem Metrics(0), GetSystemMetric s(1))
              End Function

              Originally posted by vdraceil
              thanks for ur reply..
              after finding out the resolution of the monitor,what do i do?
              how do i size my form accordingly?i mean what size should i hav for one resolution and what for some other resolution?
              how do i proceed??
              an example would help..

              Comment

              • vdraceil
                New Member
                • Jul 2007
                • 236

                #8
                Originally posted by ubentook
                This code from Jim Cone worked for me...

                Declare Function GetSystemMetric s Lib "user32" (ByVal nIndex As Long) As Long

                Sub ResizeForm_R1()
                ' Adjusts userform size to compensate for screen resolution changes.
                ' Calls function GetSR
                ' Jim Cone - San Francisco, USA - Dec 2006
                Dim varSize As Variant
                Dim RatioX As Single
                Dim RatioY As Single
                Dim ActualX As Long
                Dim ActualY As Long

                'Screen resolution in development environment.
                'Adjust as necessary <<<
                Const BaseX As Long = 800
                Const BaseY As Long = 600

                'Call function to get actual screen resolution
                varSize = GetSR
                ActualX = varSize(0)
                ActualY = varSize(1)

                'Determine ratio of actual screen resolution to
                'the original or base resolution.
                RatioX = ActualX / BaseX
                RatioY = ActualY / BaseY

                'Adjust userform magnification and size.
                UserForm1.Zoom = (100 * ((RatioX + RatioY) / 2))
                UserForm1.Width = UserForm1.Width * RatioX
                UserForm1.Heigh t = UserForm1.Heigh t * RatioY
                UserForm1.Show
                Unload UserForm1
                Set UserForm1 = Nothing
                End Sub

                '---------------------------------
                Public Function GetSR() As Variant
                ' x and y
                GetSR = Array(GetSystem Metrics(0), GetSystemMetric s(1))
                End Function
                This is only to keep a constant size form,isnt it?
                Will it work for other controls too?
                (I've not tried it yet)

                Code:
                UserForm1.Zoom = (100 * ((RatioX + RatioY) / 2))
                Considering the above code,in vb6, a form doesnt have a "zoom" property!!

                Comment

                Working...