Results 1 to 5 of 5

Thread: How to Auto-Resize form?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    Good day, mate!

    i'm wondering... how do we resize the application form if we change our screen resolution from higher resolution to lower resolution, e.g from 1024 x 768 to 800 x 600 ?

    for example:
    when i develop a program, i need the form to be maximised to allow user to see and use the whole application. but i did the program in a 1024 x 768 resolution. now, one of my user uses a 800 x 600 resolution. so, when the user try to run my application, he/she can't see half of the screen as the form has overlapped the window screen. please don't tell the user to change the resolution as the monitor is a 14 inch monitor. by the way, the display card can't support that high resolution as it's an old machine. and also tell me to develop the thing again on 800 x 600 resolution.

    I wonder is there any API or Active X that i can look into, in order to solve my problem?

    Your help is much appreciated....Thanks

  2. #2
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    maybe you can check this out
    http://www.vb-world.net/controls/resizeocx/

    or you can resize everythinb by your own.

    hth

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    thanks c@lle...

    i'll take a look into the URL to see whether it does what i want...

    thanks again...

  4. #4
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    or try this http://www.vb-world.net/controls/tip489.html

    Code:
    Private lngFormWidth As Long
    Private lngFormHeight As Long
    
    Private Sub Form_Load()
        
        Dim Ctl As Control
        
        'Store form dimensions in variables
         
        lngFormWidth = ScaleWidth
        lngFormHeight = ScaleHeight
            
        'Store initial control dimensions
        'in the Tag property - with error
        'handling for those controls which
        'do not have properties such as Top
        '(eg, Line control)
        
        On Error Resume Next
        
        For Each Ctl In Me
            Ctl.Tag = Ctl.Left & " " & Ctl.Top & " " & _
                Ctl.Width & " " & Ctl.Height & " "
                Ctl.Tag = Ctl.Tag & Ctl.FontSize & " "
        Next Ctl
        
        On Error GoTo 0
    
    End Sub
    
    Private Sub Form_Resize()
    
        Dim D(4) As Double
        Dim i As Long
    
        Dim TempPoz As Long
        Dim StartPoz As Long
    
        Dim Ctl As Control
        Dim TempVisible As Boolean
    
        Dim ScaleX As Double
        Dim ScaleY As Double
    
            'Calculate the scale
            
        ScaleX = ScaleWidth / lngFormWidth
        ScaleY = ScaleHeight / lngFormHeight
    
        On Error Resume Next
    
        'Cycle through each control
            
        For Each Ctl In Me
            TempVisible = Ctl.Visible
            Ctl.Visible = False
            StartPoz = 1
                
            'Read data from the Tag property
                 
            For i = 0 To 4
                TempPoz = InStr(StartPoz, Ctl.Tag, " ", _
                    vbTextCompare)
                         
                If TempPoz > 0 Then
                    D(i) = Mid(Ctl.Tag, StartPoz, _
                        TempPoz - StartPoz)
                    StartPoz = TempPoz + 1
                Else
                    D(i) = 0
                End If
                          
                'Move the control based on data
                'in the Tag property and the form
                'scale...
                
                Ctl.Move D(0) * ScaleX, D(1) * ScaleY, _
                    D(2) * ScaleX, D(3) * ScaleY
                Ctl.Width = D(2) * ScaleX
                Ctl.Height = D(3) * ScaleY
                
                'Change font size
                
                If ScaleX < ScaleY Then
                       Ctl.FontSize = D(4) * ScaleX
                Else
                       Ctl.FontSize = D(4) * ScaleY
                End If
                
            Next i
            
            Ctl.Visible = TempVisible
            
        Next Ctl
        
        On Error GoTo 0
        
    End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    thanks again, c@lle...

    u've been of great help...

Posting Permissions

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



Click Here to Expand Forum to Full Width