Destroying ActiveX Controls

An ActiveX control incorporated in an IDL widget hierarchy is destroyed when any of the following occurs:

In most cases, cleanup of an application that includes an ActiveX control is not different from an application using only IDL native widgets. However, because it is possible for an ActiveX control to return references to other COM objects to IDL, you must be sure to keep track of all objects created by your application and destroy them as necessary. See References to Other COM Objects for details.

In addition, it is possible for the widget event structure generated by an ActiveX control to include IDL pointers or object references. Pointers and object references included in the event structure are not automatically destroyed. See Dynamic Elements in the ActiveX Event Structure for more information.