Wrapping OCXs with extended widgets
The Common Widgets Extended Widgets framework can be used to wrapper an OleControl so it can be used in a more familiar way. That is, Smalltalk accesssors are used to wrap the OleControl property messages (propertyAt: and propertyAt:put:) and invoke message (invoke:withArguments:), and the Common Widgets callback style is used for all the OLE events of interest.
For a reference on building Extended Widgets, see the Extended Widgets. The main approach is to:
1. Make a subclass CwExtentedPrimitive.
2. Create an instance of OleControl in the Extended Widgets createPrimaryWidget:parent:argBlock: method and register an ambient-property handler. For example:
createPrimaryWidget: theName parent: parent argBlock: argBlock
"Private - Create and answer the basic widget that is the root
of the widget hierarchy for the receiver's widget system."
^self parent
createOleControl: 'the control'
argBlock: :w | w
clientName: 'TRACKBAR.TrackbarCtrl.1';
ambientPropertyReceiver: self;
ambientPropertySelector: #dispidAmbientPropertyAt:].
3. Register OLE event handlers and associate them with Common Widgets callbacks in the initializeAfterCreate method. For example:
initializeAfterCreate
"Private - Perform any widget-specific post-create initialization."
super initializeAfterCreate.
self primaryWidget
addOleEventHandler: 'Change'
receiver: self
selector: #callValueChangedCallback
Implement widget-specific methods, such as:
clearSelection
"Clears the slider's selection range."
^self primaryWidget
invoke: 'ClearSelection'
withArguments: #()
Implement accessors for resources, such as:
lineSize: resourceValue
"Set the value of the XmNlineSize resource.
Resource type: Integer
Default setting: 10
Resource access: CSG
Description: Specifies the line size. This is the amount
that the slider moves when receiving a key press."
self primaryWidget propertyAt: 'LineSize' put: resourceValue
lineSize
"Answer the value of the XmNlineSize resource.
Resource type: Integer
Default setting: 10
Resource access: CSG
Description: Specifies the line size. This is the amount
that the slider moves when receiving a key press."
self primaryWidget propertyAt: 'LineSize'
Last modified date: 01/29/2015