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:
- Associate the control-frame with a widget pool in the CREATE statement. When you delete the widget pool, Progress deletes the control-frame widget and also releases its control-frame COM object. This is the default technique used by the AppBuilder. (The AppBuilder uses the default unnamed widget pool that is deleted when the .w ends.)
- Explicitly delete the control-frame using the DELETE WIDGET statement. This statement deletes the control-frame widget and also releases the control-frame COM object.
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:
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 |