Jobs
Author: GAMEGUY Date Submitted: 6/4/2007 Category: Forms Compatibility: VB 6 This code has been accessed 5610 times.
Email Yourself this snippet:
Paste code into a module and save the module for later use. All directions are in the module comments.
Code
'Created by Brendan Nichols '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