Venkat
Here you are...
dll code:
form code:Code:Option Explicit Dim PrevResizeX As Single Dim PrevResizeY As Single Private m_Parent As Object Public Property Let Parent(ByVal Parent As Object) On Error Resume Next Set m_Parent = Parent End Property Public Property Get Parent() As Object ' Return a reference to the parent object. On Error Resume Next Set Parent = m_Parent End Property Public Sub venkatIt() 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 = m_Parent.ScaleWidth PrevResizeY = m_Parent.ScaleHeight Exit Sub End If For Each tmpControl In m_Parent '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 * m_Parent.ScaleWidth tmpControl.X2 = tmpControl.X2 / PrevResizeX * m_Parent.ScaleWidth tmpControl.Y1 = tmpControl.Y1 / PrevResizeY * m_Parent.ScaleHeight tmpControl.Y2 = tmpControl.Y2 / PrevResizeY * m_Parent.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 * m_Parent.ScaleWidth tmpControl.Top = tmpControl.Top / PrevResizeY * m_Parent.ScaleHeight tmpControl.Width = tmpControl.Width / PrevResizeX * m_Parent.ScaleWidth tmpControl.Height = tmpControl.Height / PrevResizeY * m_Parent.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 = m_Parent.ScaleWidth PrevResizeY = m_Parent.ScaleHeight 'Changes prevresize x and y to current width 'and height End Sub
I'll let you know where to send the consultancy fees to!Code:Option Explicit Dim sizer As Object Private Sub Form_Load() Set sizer = New Project1.Class1 sizer.Parent = Me End Sub Private Sub Form_Resize() sizer.venkatIt End Sub![]()
![]()
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company




Reply With Quote