Progress
AppBuilder
Developer’s Guide
Configuring an ActiveX Object Instance
Because OCX controls are not native to the Progress system, configuring them is a slightly more complicated process than configuring a comparable 4GL widget. AppBuilder generates a control_load() procedure to handle generic initialization of OCX objects. That procedure performs three tasks:
At this point, you must take over. You must perform some number of tasks that are object-dependent. In general, you must:
- Assign a meaningful identifier to the object—or, more exactly, to its Control Frame. You need do nothing with the identifier (the Name property) of the OCX object itself.
- Write the initialize-controls() procedure if you want to do special initialization.
- Select the events you wish to handle for this object and create procedures to do that.
- Size and position the object image within the workspace.
The following walkthrough presumes you are placing an instance of the Spin Control that AppBuilder supplies in the Objects Palette. Follow these steps:
- Create a Window workspace and set the Message Area property, so that the workspace will be able to display messages conveniently.
- Click on the Spin Control tool icon in the Objects Palette:
![]()
- Move your mouse cursor over a bare spot in your workspace and click to place the instance. The default size will probably be too large—temporarily resize it now:
![]()
- Note that AppBuilder’s main window displays two Object identifiers. Replace the editable identifier (CtrlFrame) with one that is more meaningful in the context of your application. For this example, use iSpinBox:
![]()
![]()
- Press F2 to run the workspace momentarily, which forces AppBuilder to create the control_load() procedure. (This is not a step you need normally take; it is included here only for the sake of the example.) Stop the run as soon as you like. Choose Window
Code Section Editor. When the editor window opens, select Procedures as the Section, and control_load as the procedure:
![]()
Note these lines of code:
AppBuilder creates the COM–HANDLE identifier by prepending the digraph “ch” to whatever identifier you assigned to the Control Frame object. In this case, the Control Frame identifier is iSpinBox, so the handle is chiSpinBox. AppBuilder initializes the handle by assigning the Control Frame’s COM–HANDLE property.
AppBuilder then uses that COM–HANDLE to call LoadControls(), and finally inserts a generic call to the optional initialize–controls() routine.
- Choose the New button. The New Procedure dialog box opens:
![]()
- Type in initialize–controls as the procedure name. (Be careful not to use an underscore, if you are used to writing C.) Set Type to Procedure, if necessary, and choose OK. Section Editor generates a new stub routine.
- Insert these lines of code:
Note how the code refers to the properties. The reference is not via the COM–HANDLE variable directly because that refers to the COM object layer in the adaptive interface, not to the ActiveX object itself. You must use an indirect reference, combining the COM–HANDLE , OCX, and property identifiers:
NOTE: The color-coding and all-caps appearance of certain properties, as shown here, is an artifact of the Section Editor settings. Those attributes are not significant in any way, and you can change them to suit yourself.
![]()
- Change Section to Definitions and define a variable to represent the current spin value:
- Change Section to Triggers, and choose New. The dialog box will open:
![]()
- Select OCX.SpinUp and choose OK. Section Editor generates a new stub event handler. Insert these lines of code to complete it:
- Choose New again, and create a trigger for the OCX.SpinDown event. Use the same code.
Run the workspace. You should see the Spin Control initialized to 5, and your “Control Initialized” message:
![]()
When you operate the arrowhead buttons in the control, you should see the values change in increments of 100, to the limits –495 and 905:
![]()
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |