An OleClient widget provides an OLE container the place to put embedded or linked OLE objects. An
OleClient is a primitive widget, thus conforms to all standard management of widget geometry. An
OleClient widget contains a connection to an embedded or linked OLE object and transparently manages all low-level OLE interaction with that object. The contained OLE object renders its content on the
OleClient widget, which may be configured to allow the user to resize its area or move it within its enclosing window.
OleClient widgets are created and managed like other primitive widgets. However, there are several techniques for creating and connecting an embedded or linked OLE object to an
OleClient widget.
To create an OLE object and connect it with an OleClient widget, the OLE object's server must be registered in the system registry, which is often called the "registration database". One of the attributes of the registration is the programmatic identifier, or
ProgId, which identifies the registered OLE object. The ProgId of a registered OLE object is the name used for the
clientName resource of an
OleClient.
Here, the clientType resource is set to
XmEMBEDDED and specifically requests that the OLE object named 'Word.Document.6' be embedded into the new
OleClient. This code fragment creates an
OleClient widget that contains an empty embedded Microsoft Word document. Double-clicking anywhere on the
OleClient widget causes Microsoft Word to be activated in place and ready for editing the embedded document.
Creating an OleClient from an OLE object server's data file is similar to creating by name. To create from a file, the file must already be created by the OLE server.
The OleClient is created to be linked to the same document file by changing the
clientType resource to
XmLINKED. For example, an
OleClient is created to be linked to a Microsoft Word document file using:
In this example, the OleClient is first created with an initial position and size. The
OleClient widget is then managed. It is not, however, made visible to you using
mappedWhenManged: false until the embedded or linked OLE object is created and connected to the widget. The parameter to
promptInsertObject: specifies what kind of OLE object can be inserted in the widget. If
XmANY is specified, for example, you can select the
Create from File option in the dialog and then optionally select
Link.
If promptInsertObject: answers
true, an OLE object was created and connected to the
OleClient widget, which can then be mapped with the message
client mappedWhenManaged: true.
If promptInsertObject: answers
nil, you canceled the dialog. However, if it answers
false, the creation of the OLE object failed.
An OleClient can be queried to determine whether it is embedded or linked by sending
isEmbedded or
isLinked.
In this example as in the one before it, the OleClient is first created with an initial position and size. The
OleClient widget is then managed but not made visible to you until the OLE object is created and connected to the widget. The parameter to
promptPasteSpecial: takes the same values as
promptInsertObject:. If
XmANY is specified, for example, you can select the
Paste Link option in the dialog to create a linked OLE object.
If promptPasteSpecial: answers
true, an OLE object was created and connected to the
OleClient widget. The widget can then be mapped and the OLE object made visible.
If promptPasteSpecial: answers
nil, you canceled the dialog. However, if it answers
false, the creation of the OLE object failed.
Copyright 2005, 2018 Instantiations, Inc. All rights reserved.