Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : ActiveX Control Support : Accessing ActiveX controls at runtime : Accessing the control handle : Using the Control-Name property of the control container
 
Using the Control-Name property of the control container
This example show how you might access the component handle to the CSSpin control using the Control-Name property:
DEFINE VARIABLE chCSSpin    AS COM-HANDLE. /* ActiveX Control */
DEFINE VARIABLE CtrlFrame   AS HANDLE.     /* Control-Frame Widget */
DEFINE VARIABLE chCtrlFrame AS COM-HANDLE. /* Control-Frame COM Object */
DEFINE VARIABLE OCXFile     AS CHARACTER   /* .wrx file pathname */

/* Define a FRAME widget named 'Foo' */

/* Create OCX Container */

CREATE CONTROL-FRAME CtrlFrame ASSIGN /
  FRAME = FRAME Foo:HANDLE.
CtrlFrame:NAME = "CtrlFrame":U.

/* Load (instantiate) ActiveX control */

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

chCSSpin = chCtrlFrame:CSSpin /* Control handle via the Control Name */
The bolded code is the code you might add to appropriate sections of your application; the rest is a simplified version of code the AppBuilder might generate. Note how the AppBuilder uses the control-frame name (CtrlFrame) to generate handle variable names and to locate the control instance in the csspinapp.wrx file. The actual control name (CSSpin) is the OCX name specified for the control at design time (in this case, the CSSpin default).