Using automation aspects of an OCX
OCXs are also OLE automation objects; that is, they have properties that can be set and retrieved, and they have functions that can be invoked on behalf of their containers.
To support its OLE automation aspects, the OleControl class has the same automation protocols as the OleAutomationObject class, namely:
propertyAt:
propertyAt:put:
invoke:withArguments:
invoke:withArguments:returnType:
Since complex OCXs are often composed of many distinct objects, some of these methods may themselves return OLE automation objects.
The properties that an OCX defines are characteristic of the OCX. These characteristics can include the font used, the background color, or the caption. Since so many of these characteristics are common to so many OCXs, OLE has defined a set of standard property DISPIDs for them. A set of constants for these DISPIDs is also defined in the PlatformConstants pool dictionary. (See the Standard Property DISIDs in the table below.)
As an example of setting properties, the following code fragment initializes the track bar OCX created in the previous example:
trackBar
propertyAt: 'SliderStyle' put: 0 "Enable selection range";
propertyAt: 'SelectionStart' put: 1;
propertyAt: DispidEnabled put: true;
propertyAt: 'SelectionEnd' put: 100;
invoke: 'SetTicFrequency' withArguments: (Array with: 1 with: 5)
 
Standard Property DISPID
Class
Specifies
DispidBackcolor
Integer
The color of the interior of the OCX (in RGB values)
DispidBackstyle
Integer
Whether an OCX is transparent (0) or opaque (1)
DispidForecolor
Integer
The color of the display of text and graphics in an OCX (in RGB values)
DispidEnabled
Boolean
Whether the OCX can receive the focus
DispidText
String
The string to be displayed in a text box, list box, or combo box
DispidCaption
String
The string to be displayed in, or next to, the OCX
DispidRefresh
None
Force repainting the OCX synchronously if the OCX has a window, otherwise asynchronously
DispidDoclick
None
Simulate the button being clicked by the user (for button-like OCXs)
DispidAboutbox
None
Pop up a modal About dialog for the OCX
Note:
The font property DISPID DispidFont is not supported. Instead, use the fontList: instance method of OleControl to set a font into an OCX.
Last modified date: 01/29/2015