Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : ActiveX Control Support : Managing ActiveX controls at runtime : Releasing control resources : Releasing ActiveX controls
 
Releasing ActiveX controls
When you delete a control-frame widget, ABL also automatically releases the control-frame COM object as well as any references to the ActiveX control held by the control-frame. You must release all other COM objects using the RELEASE OBJECT statement:
DEFINE VARIABLE CtrlFrame    AS HANDLE     NO-UNDO.
DEFINE VARIABLE chCtrlFrame  AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chCSSpin     AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chCollection AS COM-HANDLE NO-UNDO.

/* Create frame Foo and instantiate control */
CREATE CONTROL-FRAME CtrlFrame
ASSIGN
FRAME = FRAME Foo:HANDLE
NAME  = "CtrlFrame":U.

chCtrlFrame = CtrlFrame:COM-HANDLE.
chCtrlFrame:LoadControls("csspinapp.wrx":U, "CtrlFrame":U).

chCollection        = chCtrlFrame:controls.
chCSSpin            = chCollection:Item(1).
chCSSpin:ShadeColor = RGB-VALUE(0,128,0).
RELEASE OBJECT chCollection.

/* Do some more stuff ... WAIT-FOR ... */

DELETE WIDGET CtrlFrame.
This example releases the control collection after it is no longer needed. It also deletes the control-frame using the DELETE WIDGET statement, which also releases the chCtrlFrame COM object as well as the ActiveX control itself (chCSSpin).