VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Resizes Objects on form as form resizes

by GAMEGUY (4 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 6th April 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Resizes Objects on form as form resizes

Rate Resizes Objects on form as form resizes




'Use:
'On load form:

'Call GetPos(Frm as Form, resize_text as boolean)

'Notes:
'Resize_text = true then text is resized as form is resized
'resize_text must be the same in getpos as in resizeform


'In form_resize:

'Call ResizeForm(frm as form, resize_text as boolean)


Global Ratio(10000) As Double

Global x As Integer

Public Sub GetPos(Frm As Form, resize_text As Boolean)
x = 0
Dim c As Control
For Each c In Frm.Controls
    Ratio(x) = c.Width / Frm.Width
    Ratio(x + 1) = c.Height / Frm.Height
    Ratio(x + 2) = c.Left / Frm.Width
    Ratio(x + 3) = c.Top / Frm.Height
    If c.FontSize > 0 And resize_text = True Then
        Ratio(x + 4) = c.FontSize / (Frm.Height * Frm.Width)
        x = x + 5
    Else
        x = x + 4
    End If
Next c
End Sub

Public Sub ResizeForm(Frm As Form, resize_text As Boolean)
x = 0
Dim c As Control
For Each c In Frm.Controls
    c.Width = Frm.Width * Ratio(x)
    c.Height = Frm.Height * Ratio(x + 1)
    c.Left = Frm.Width * Ratio(x + 2)
    c.Top = Frm.Height * Ratio(x + 3)
    If c.FontSize > 0 And resize_text = True Then
        c.FontSize = Int((Frm.Height * Frm.Width) * Ratio(x + 4))
        x = x + 5
    Else
        x = x + 4
    End If
Next c
End Sub


Download this snippet    Add to My Saved Code

Resizes Objects on form as form resizes Comments

No comments have been posted about Resizes Objects on form as form resizes. Why not be the first to post a comment about Resizes Objects on form as form resizes.

Post your comment

Subject:
Message:
0/1000 characters