Creating OCXs
An OleControl widget provides an OLE container the place to put OCXs. OLE controls are primitive widgets and, as such, they conform to all standard widget-geometry management. An OleControl widget contains the connections to an OCX and transparently manages all low-level OLE interaction with that object. In addition, an OleControl widget provides an OLE automation interface for its contained OCX to be used to set and get OCX properties and to invoke OCX methods.
OleControl widgets are created and managed like other primitive widgets. Unlike OleClient widgets, however, the only way to create and connect an OCX to an OleControl widget is through its registered name. This is the same as the creation of OLE clients using the clientName resource, which is based on the OCX's registered programmatic identifier, or ProgId.
Since OLE controls are also created as child widgets of any non-primitive widget (that is, any CwComposite), there is an additional widget-creation convenience method implemented in CwWidget, called createOleControl:argBlock:. The creation block passed to this method must not only specify the clientName resource (through the clientName: method) but also the ambient-property handler, or callback, to be used by the contained OCX. This ambient-property handler is specified through the OleControl instance methods ambientPropertyReceiver: and ambientPropertySelector:.
The ambient-property handler must be specified when the OleControl widget is created, so that the OCX has access to the container's properties during its initialization. As an example, consider a container that uses a track bar OCX that is created using:
createTrackBar: workWindow
"Private - Create a track bar control."
trackBar := workWindow
createOleControl: 'the control'
argBlock: [:w |
w
clientName: 'TRACKBAR.TrackbarCtrl.1';
ambientPropertyReceiver: self;
ambientPropertySelector: #dispidAmbientPropertyAt:].
trackBar manageChild.
Last modified date: 01/29/2015