Progress
External Program
Interfaces


Releasing Control Resources

The following material describes the process of creating and freeing control-frame widgets. This is automatically done by the AppBuilder, but, like any other dynamic widget, you can delete a control-frame some time after you create it.

You can delete a control-frame using two techniques:

Releasing ActiveX Controls

When you delete a control-frame widget, Progress 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 WIDGET-HANDLE. 
DEFINE VARIABLE chCtrlFrame AS COM-HANDLE.
DEFINE VARIABLE chCSSpin AS COM-HANDLE.
DEFINE VARIABLE chCollection AS COM-HANDLE.

/* 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).

Releasing COM Objects Individually

If you try to release an ActiveX control (using the RELEASE OBJECT statement) before the control-frame is deleted, this works but is unnecessary. If you try to access a control after the control-frame is deleted, Progress displays an error message that you are trying to reference an invalid component handle.

Because you have a component handle to a control-frame COM object, you might think you can release it using the RELEASE OBJECT statement. However for control-frame COM objects, Progress does not allow this because of the link between the control-frame widget and COM object.

Thus, you can only release the control-frame COM object by deleting the control-frame widget. If you do try to release the component handle of a control-frame, Progress returns an error indicating that you should delete the object through the widget handle instead.

In general, if you do not delete or release any COM objects in an application, all active COM objects remain instantiated until the end of the Progress session, at which time Progress automatically releases them.

For more information on releasing COM object resources, see Using COM Objects In the 4GL."


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095