Using licensed OCXs
Many commercially available OCXs limit developer usage through licensing. With licensing, an OCX fails creation unless it is provided with the correct license key. The vendor of the OCX provides the license key in a file. The license must be obtained from the license file at development time and then cached for use during the runtime creation of the OCX.
To support the use of licensed OCXs, the OleControl class has the class method getLicenseKey:, which is used at development time to obtain the license key. This method takes as a parameter the ProgId of the OCX and answers a string representing the license key. The license key is then cached in the Smalltalk image (for example, in a class variable of an Extended Widgets wrapper of the OCX) and used in the subsequent creation of the OleControl widget.
For example, if the track bar OCX is licensed, its license key is obtained using the following code:
"Answer a string that can be used to license the receiver,
or nil if either the OCX does not require licensing
or the OCX does support licensing but cannot be propagated."
LicenseKey := OleControl getLicenseKey: 'TRACKBAR.TrackbarCtrl.1'
LicenseKey is a class variable of the Extended Widgets class.
Then the createPrimaryWidget:parent:argBlock: method is changed to be as follows:
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';
licenseKey: LicenseKey;
ambientPropertyReceiver: self;
ambientPropertySelector: #dispidAmbientPropertyAt:].
The licenseKey: method must be used in the create block of the OleControl.
Last modified date: 01/29/2015