Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Resize at run-time 1

Status
Not open for further replies.

AOLBoy

IS-IT--Management
May 7, 2002
68
GB
Any ideas on how I can allow the user to resize a form at run-time and to apply the resize to all controls on the form.
Thanks
 
You mean something like this?:

Option Explicit
Dim PrevResizeX As Long
Dim PrevResizeY As Long


Public Function ResizeAll(FormName As Form)
Dim tmpControl As Control
On Error Resume Next
'Ignores errors in case the control does
' n't
'have a width, height, etc.


If PrevResizeX = 0 Then
'If the previous form width was 0
'Which means that this function wasn't r
' un before
'then change prevresizex and y and exit


' function
PrevResizeX = FormName.ScaleWidth
PrevResizeY = FormName.ScaleHeight
Exit Function
End If


For Each tmpControl In FormName
'A loop to make tmpControl equal to ever
' y
'control on the form


If TypeOf tmpControl Is Line Then
'Checks the type of control, if its a
'Line, change its X1, X2, Y1, Y2 values
tmpControl.X1 = tmpControl.X1 / PrevResizeX * FormName.ScaleWidth
tmpControl.X2 = tmpControl.X2 / PrevResizeX * FormName.ScaleWidth
tmpControl.Y1 = tmpControl.Y1 / PrevResizeY * FormName.ScaleHeight
tmpControl.Y2 = tmpControl.Y2 / PrevResizeY * FormName.ScaleHeight
'These four lines see the previous ratio
'
'Of the control to the form, and change
' they're
'current ratios to the same thing
Else
'Changes everything elses left, top
'Width, and height
tmpControl.Left = tmpControl.Left / PrevResizeX * FormName.ScaleWidth
tmpControl.Top = tmpControl.Top / PrevResizeY * FormName.ScaleHeight
tmpControl.Width = tmpControl.Width / PrevResizeX * FormName.ScaleWidth
tmpControl.Height = tmpControl.Height / PrevResizeY * FormName.ScaleHeight
'These four lines see the previous ratio
'
'Of the control to the form, and change
' they're
'current ratios to the same thing
End If
Next tmpControl
PrevResizeX = FormName.ScaleWidth
PrevResizeY = FormName.ScaleHeight
'Changes prevresize x and y to current w
' idth
'and height
'Form1.Text1(0).SetFocus

End Function


 
Brilliant ponerse, thanks very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top