Timer control disables Terminate event of ActiveX control 
Author Message
 Timer control disables Terminate event of ActiveX control

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 ??

Thanks for any help,
Bhasker.



Sun, 05 Dec 2004 13:00:34 GMT  
 Timer control disables Terminate event of ActiveX control
Hi all,

Please let me know if you were able to simulate the issue.
If you were not able to simulate the same, I could send
you the VB project.

Bhasker.

Quote:
>-----Original Message-----
>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
Quote:
>= True' call the 'Terminate' method when the ActiveX

control is destroyed.

- Show quoted text -

Quote:

>Any idea why this happens ??

>Thanks for any help,
>Bhasker.

>.



Sat, 11 Dec 2004 14:01:04 GMT  
 Timer control disables Terminate event of ActiveX control

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.


Sun, 12 Dec 2004 10:32:19 GMT  
 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.



Sun, 12 Dec 2004 18:57:55 GMT  
 Timer control disables Terminate event of ActiveX control

Quote:

> 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

Why are you setting x to the checkbox?

If you simply want to access the check box from outside, then use a Property
Get.

--
Regards,

Michael Cole



Mon, 13 Dec 2004 09:21:30 GMT  
 Timer control disables Terminate event of ActiveX control
Hi,

The actual scenario is something like this :

I have two grid controls on my ActiveX control form. At any given time, only
one of them will be visible. When large amount of data is being fetched, the
invisible grid is populated (to avoid flickering and other not-so-nice GUI
operations on the grid) at the background (through a timer). When the data
is fetched completely, the visible state of the two grids is swapped and x
(equated to a checkbox in my code) will actually point to the currently
active (visible) grid. This will help in having just one grid object (i.e.,
x) for both the grids, and therefore, my code becomes generic (with respect
to accessing methods of the grids and its events).

Bhasker.


Quote:

> > 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

> Why are you setting x to the checkbox?

> If you simply want to access the check box from outside, then use a
Property
> Get.

> --
> Regards,

> Michael Cole



Tue, 14 Dec 2004 12:32:14 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Terminate Event on ActiveX user control not firing

2. Calling a sub from a the timer event of a timer control

3. Timer Control and ActiveX control

4. timer control ticks after disabling

5. raising an event from an activeX control on a htm page in a webbrower control

6. Timer control disables Windows screen saver

7. Detecting developer dropping controls into ActiveX control container - VB5 Events

8. raising an event from an activeX control on a htm page in a webbrower control

9. WebBrowser control doesn't terminate in ActiveX document

10. Terminating an ActiveX control

11. Why no Terminate in ActiveX control?

12. WebBrowser control doesn't terminate in ActiveX document

 

 
Powered by phpBB® Forum Software