RELEASE OBJECT statement

Releases the specified COM object (Automation object or ActiveX control) and removes all internal structures associated with the handle to the object.

Syntax

RELEASE OBJECT COM-hdl-var[ NO-ERROR ]
COM-hdl-var
A COM-HANDLE variable that references a valid COM object.
NO-ERROR
The NO-ERROR option is used to prevent the statement from raising ERROR and displaying error messages.

Example

This procedure fragment shows a control named hc_CmdButton being loaded into a control-frame and the handle to the control (controlHdl) being obtained using the control name (hc_CmdButton) property. Later, it releases the control and deletes the parent control-frame widget (CFWidHdl).

DEFINE VARIABLE CFWidHdl   AS HANDLE     NO-UNDO.
DEFINE VARIABLE CFComHdl   AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE controlHdl AS COM-HANDLE NO-UNDO.

/* Create frame foo ... */
CREATE CONTROL-FRAME CFWidHdl ASSIGN 
  FRAME = FRAME foo:HANDLE
  NAME  = "ctlFrame1".

CFComHdl = CFWidHdl:COM-HANDLE.
CFComHdl:LoadControls(hc_CmdButton.wrx, "hc_CmdButton").

controlHdl = CFComHdl:hc_CmdButton.
controlHdl:BgColor = RGB-VALUE(0,128,0).

/* Do some more stuff ... WAIT-FOR ... */
RELEASE OBJECT controlHdl. /* NOTE: Not really necessary */
DELETE WIDGET CFWidHdl.

For an example of the RELEASE OBJECT statement applied to Automation objects, see the CREATE automation object statement entry.

Notes

See also

CREATE automation object statement, DELETE WIDGET statement, DELETE WIDGET-POOL statement, NO-ERROR option