Results 1 to 8 of 8

Thread: Dynamic form Sizing

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2006
    Posts
    139

    Dynamic form Sizing

    Hi Everyone,

    Can you code a program in VB6 to be dynamic in regards to the size of the form? For example, If a user wants the program to be maximized, he'll hit the maximize buttom and the program will go full screen. In going full screen, the txtboxes, listboxes, etc... all expand to fit the size of the screen. Same goes for all sizes inbetween. The program expands and contracts to fit the size of the form the user wants.

    If this is possible, could someone tell how to do it, or direct to me information regarding this. Thank you.
    Last edited by skakels; Apr 13th, 2006 at 01:57 PM.

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Dynamic form Sizing

    to resize components at runtime, see the link in my signature.

    to make window go FullScreen, check these 2 links:

    Link 1

    Link 2

    Harsh
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Registered User
    Join Date
    Apr 2006
    Posts
    139

    Re: Dynamic form Sizing

    Harsh,

    I need everything inside the form to adjust to the size as well. I'm trying to mimic how the attached program works when you change sizes of the main form.

    http://www.1337computers.net/jim/ARISetup0643.zip

  4. #4
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Dynamic form Sizing

    Quote Originally Posted by ME
    to resize components at runtime, see the link in my signature.


    ReSizing Controls on Form

    is this what you wanted?? sorry but i am not able to open the link you posted, problem with my net connection.

    Harsh
    Show Appreciation. Rate Posts.

  5. #5
    Lively Member
    Join Date
    Mar 2004
    Location
    Newcastle
    Posts
    114

    Re: Dynamic form Sizing

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type CtrlProportions
    4.     HeightProportions As Single
    5.     WidthProportions As Single
    6.     TopProportions As Single
    7.     LeftProportions As Single
    8. End Type
    9.  
    10. Dim ProportionsArray() As CtrlProportions
    11.  
    12. Sub InitResizeArray()
    13.  
    14.     Dim i As Integer
    15.    
    16.     On Error Resume Next
    17.    
    18.     ReDim ProportionsArray(0 To Controls.Count - 1)
    19.    
    20.     For i = 0 To Controls.Count - 1
    21.         With ProportionsArray(i)
    22.             .HeightProportions = Controls(i).Height / ScaleHeight
    23.             .WidthProportions = Controls(i).Width / ScaleWidth
    24.             .TopProportions = Controls(i).Top / ScaleHeight
    25.             .LeftProportions = Controls(i).Left / ScaleWidth
    26.         End With
    27.     Next i
    28.    
    29. End Sub
    30.  
    31. Sub ResizeControls()
    32.  
    33.     On Error Resume Next
    34.    
    35.     Dim i As Integer
    36.    
    37.     For i = 0 To Controls.Count - 1
    38.         With ProportionsArray(i)
    39.             ' move and resize controls
    40.             Controls(i).Move .LeftProportions * ScaleWidth, _
    41.             .TopProportions * ScaleHeight, _
    42.             .WidthProportions * ScaleWidth, _
    43.             .HeightProportions * ScaleHeight
    44.         End With
    45.     Next i
    46.    
    47. End Sub
    48.  
    49. 'Form initialize event
    50. Private Sub Form_Initialize()
    51.  
    52.     InitResizeArray
    53.    
    54. End Sub
    55.  
    56. 'Form resize event
    57. Sub Form_Resize()
    58.  
    59.     ResizeControls
    60.    
    61. End Sub

  6. #6
    Member Birth's Avatar
    Join Date
    Jan 2003
    Location
    Montreal
    Posts
    57

    Re: Dynamic form Sizing

    Hi,

    I've seen this code all over the forum and it works great.


    Code:
    Private Type CtrlProportions
        HeightProportions As Single
        WidthProportions As Single
        TopProportions As Single
        LeftProportions As Single
    End Type
    
    Dim ProportionsArray() As CtrlProportions
    
    Sub InitResizeArray()
    
        Dim i As Integer
        
        On Error Resume Next
        
        ReDim ProportionsArray(0 To Controls.Count - 1)
        
        For i = 0 To Controls.Count - 1
            With ProportionsArray(i)
                .HeightProportions = Controls(i).Height / ScaleHeight
                .WidthProportions = Controls(i).Width / ScaleWidth
                .TopProportions = Controls(i).Top / ScaleHeight
                .LeftProportions = Controls(i).Left / ScaleWidth
            End With
        Next i
        
    End Sub
    
    Sub ResizeControls()
    
        On Error Resume Next
        
        Dim i As Integer
        
        For i = 0 To Controls.Count - 1
            With ProportionsArray(i)
                ' move and resize controls
                Controls(i).Move .LeftProportions * ScaleWidth, _
                .TopProportions * ScaleHeight, _
                .WidthProportions * ScaleWidth, _
                .HeightProportions * ScaleHeight
            End With
        Next i
        
    End Sub
    
    'Form initialize event
    Private Sub Form_Initialize()
    
        InitResizeArray
        
    End Sub
    
    'Form resize event
    Sub Form_Resize()
    
        ResizeControls
        
    End Sub
    The only problem I have is that I'd like the CommandButton to stay in place. I must have tryed everything except the right thing...

    Can anybody help?

    Thanks
    Last edited by Birth; Feb 10th, 2007 at 04:00 PM.

    ~~~~~~~~~~~~~~~~~~~~
    There's always something
    ~~~~~~~~~~~~~~~~~~~~
    <Any link censored by moderator>

  7. #7
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,235

    Re: Dynamic form Sizing

    This little app will resize all controls on a Form as you resize the Form.

    Post #7
    Keith

    I've been programming with VB for 20 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  8. #8
    Member Birth's Avatar
    Join Date
    Jan 2003
    Location
    Montreal
    Posts
    57

    Re: Dynamic form Sizing

    Yep, I tryed this one before but the Left property of the ListView Control can not be read for some reason.

    All I want is the CommandButton not to be resized.

    ~~~~~~~~~~~~~~~~~~~~
    There's always something
    ~~~~~~~~~~~~~~~~~~~~
    <Any link censored by moderator>

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