Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : ActiveX Control Support : Programming ActiveX controls in the AppBuilder : Creating data definitions for an ActiveX control
 
Creating data definitions for an ActiveX control
These fragments provide data and code definitions, including those for the spin button control, referenced by other sections of the application. The first fragment contains variable definitions that are hand-coded in the Definitions section of the AppBuilder Section Editor:
/* Local Variable Definitions --- */

DEFINE VARIABLE result      AS LOGICAL    NO-UNDO.
DEFINE VARIABLE max-records AS INTEGER    NO-UNDO.
DEFINE VARIABLE chCSSpin    AS COM-HANDLE NO-UNDO.
Note the variable to hold the component handle CSSpin ActiveX control. All other necessary widget and component handles for this application are provided by the AppBuilder.
This is the query definition assembled by the AppBuilder from user input. The PRESELECT option allows the application to know the number of records it is scanning with the spin button at startup, as shown:
/* ******************** Preprocessor Definitions ******************** */
. . .

&SCOPED-DEFINE OPEN-QUERY-Dialog-Frame OPEN QUERY Dialog-Frame PRESELECT EACH sports2000.Customer NO-LOCK.
The following code section shows relevant widget handle, component handle, and query definitions generated by the AppBuilder from user input:
/* *********************** Control Definitions ********************** */
. . .
/* Definitions of handles for OCX Containers */
DEFINE VARIABLE custSpin   AS HANDLE     NO-UNDO.
DEFINE VARIABLE chcustSpin AS COM-HANDLE NO-UNDO.
. . .

DEFINE VARIABLE iRecordCount AS INTEGER FORMAT "9999":U LABEL "Record Number"
  VIEW-AS TEXT SIZE 5.8 BY .62 NO-UNDO.
. . .

/* Query definitions */
. . .
DEFINE QUERY Dialog-Frame FOR sports2000.Customer SCROLLING.
The AppBuilder assembles the widget definitions as you add objects to the design window. Thus, the AppBuilder assembles the definitions for the control-frame handles (custSpin and chcustSpin) after you insert the spin button control into the design window. (The programmer has changed the name of the control-frame from CtrlFrame to custSpin.) The application also uses the iRecordCount variable to display the ordinal record number of each Customer record scanned by the spin button control.
You can begin setting ActiveX control properties in the OCX Property Editor Window any time after you add the control into the design window.
You cannot view or change this AppBuilder-generated code from the Section Editor. However, it is part of the .w file generated for the application, and you can use Code Preview option of the Tools menu to view this code.
The AppBuilder automatically generates the query definition from the query criteria entered earlier.
This fragment shows the actual control-frame definition created by the AppBuilder using the custSpin widget handle defined earlier. The AppBuilder creates and maintains this definition as you insert, position, and size the spin button control in the design window. Note the setting of the control-frame NAME attribute after the widget is created and parented to the Dialog-Frame frame. The AppBuilder also sets the HIDDEN attribute to no (FALSE) because the spin button control is, by default, a visible control. For example:
/* ********************** Create OCX Containers ********************** */

&ANALYZE-SUSPEND _CREATE-DYNAMIC

&IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U &THEN
CREATE CONTROL-FRAME custSpin ASSIGN
FRAME = FRAME Dialog-Frame:HANDLE
ROW = 11.19
COLUMN = 15.4
HEIGHT-CHARS = 2.33
WIDTH-CHARS  = 61.2
HIDDEN = no
SENSITIVE = yes.
custSpin:NAME = "custSpin":U .

/* custSpin OCXINFO:CREATE-CONTROL from:
{EAF26C8F-9586-101B-9306-0020AF234C9D} type: CSSpin */
custSpin:MOVE-AFTER(Btn_Update:HANDLE IN FRAME Dialog-Frame).
&ENDIF

&ANALYZE-RESUME /* End of _CREATE-DYNAMIC */
Note: You cannot view or change this AppBuilder-generated code from the Section Editor. However, it is part of the .w file generated for the application, and you can use Code Preview option of the Tools menu to view this code.
The AppBuilder also ensures, with appropriate preprocessor settings, that ABL only compiles and executes OCX-related sections of this procedure file if it is running in the graphical mode (not TTY) of a Windows system (WIN32).