|
-
Jan 9th, 2000, 03:24 PM
#1
Thread Starter
Hyperactive Member
Hi all,
Here is a piece of code that I got from somewhere...This code was used in a function and that function was called in the resize event of the form, and it works well. But I need to put this in a user control and I want it to call it in my form. I opened the usercontrol project and the code is as under;
Private Sub UserControl_Initialize()
Dim tmpControl As Control
On Error Resume Next
'Ignores errors in case the control doesn't
'have a width, height, etc.
If PrevResizeX = 0 Then
'If the previous form width was 0
'Which means that this function wasn't run before
'then change prevresizex and y and exit function
PrevResizeX = FormName.ScaleWidth
PrevResizeY = FormName.ScaleHeight
Exit Sub
End If
For Each tmpControl In FormName
'A loop to make tmpControl equal to every
'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 width
'and height
End Sub
------------------
Here is my problem
------------------
How do I call this control in my form. When i add this control after making the ocx, I am unable to make it work.Why is it so..Please help.
Regards.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|