PDA

Click to See Complete Forum and Search --> : Hell with this DLL


venkatraman_r
Jan 12th, 2000, 06:58 PM
Hello Guys,
with the help of Mr. Mark, I managed to prepared an user control that resizes all the controls in the form when the form is resized. I altered and made the code as ActiveX Dll. I made a reference to the dll in a new project. But it is not working. What could be the reaons? Where i am wrong? Someone please help me out...

Here is the code i used in the exe project where the dll reference is made.

General Declaration:
-------------------
Dim resize As New FormResize.ResizeClass
-------
Private Sub Form_Resize()
resize.venkatIt
End Sub

Venkat.



------------------
venkatraman_r@hotmail.com
ICQ: 45714766
http://venkat.iscool.net

Mark Sreeves
Jan 12th, 2000, 07:34 PM
Venkat

Here you are...

dll 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



form 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


I'll let you know where to send the consultancy fees to! :) :) :)


------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

venkatraman_r
Jan 13th, 2000, 12:11 PM
Hey Mark...

One day or the other I will be leaving for abroad....let me know ur place u live in..

If I had been the richest man, i would have showered you all with dollars..But...Still,
I will surely come give you the priceless friendship as consultancy fee....Thanx man.... ;)

Venkat.

------------------
venkatraman_r@hotmail.com
ICQ: 45714766
http://venkat.iscool.net