
Timer control disables Terminate event of ActiveX control
Hi,
Even if I say "Timer1.Enabled = False" immediately after the line
"Timer1.Enabled = True", the 'Terminate' method is not called.
However, if I say
set x = nothing
after the line
Set x = UserControl.Check1
then the terminate method is called !!
You had suggested that the timer be disabled before the control is
destroyed, but how can I determine if the control is being destroyed - the
only way is on 'Terminate' being called !!
Thanks for the suggestion,
Bhasker.
Quote:
> > Hi everybody,
> > I've devloped a VERY simple ActiveX control in VB. The following is
> > what I did :
> > ** Create a VB project (ActiveX control)
> > ** Insert a checkbox on the Usercontrol form
> > ** Insert a timer control on the Usercontrol form
> > ** Put the following code :
> > Public x As CheckBox 'In the "General" section
> > Private Sub UserControl_Initialize()
> > Timer1.Enabled = True
> > Set x = UserControl.Check1
> > End Sub
> > Private Sub UserControl_Terminate()
> > MsgBox "Terminate"
> > End Sub
> > When the above code is run, the 'Terminate' method is not called when
> > the ActiveX control is destroyed. Howerver, commenting the line
> > 'Timer1.Enabled = True' call the 'Terminate' method when the ActiveX
> > control is destroyed.
> > Any idea why this happens ??
> Possibly because whilst the timer is still active, the control cannot be
> destroyed. Before trying to destroy the control, disable the timer. Note
> that simply dropping your reference to the control will not nessesarily
> destroy the control. If the timer remains active, you now have a memory
> leak.