In this section, you build an application that uses OLE Client parts to run
Windows text and graphics editors. The finished application will look
like the following:
Begin by creating an application named ClientRecordsApp. Add a visual part to the application, and name it ClientRecordsView.
In the Composition Editor, add a menu bar, a text pane, two labels, and
three OLE Client parts to the window. The OLE Client part is in the OLE
category. Also, add three menu choices and a separator to the popup
menu. Next, add a second popup menu and add two menu choices to
it. After you add the parts, your Composition Editor shows the
following:
Resize and align the parts. Next, change the parts' labels and names:
Change the settings for the Description OLE Client part to the following:
Change the settings for the Bitmap OLE Client part:
Note: | Were you to specify values for both clientName and sourcePath, the OLE Client would initialize based upon the sourcePath. |
A linked clientType has a pointer to a file so if the file is updated, the OLE Client can access the updated version. An embedded clientType (uses XmEMBEDDED) accesses a copy of the file as it exists at the time of embedding, so the OLE Client does not access a file updated later. When you do not specify a value for clientType, the clientType of the target OLE Client container is used. If you specify XmLINKED but do not supply a valid sourcePath, the clientType of the underlying OLE Client part will be XmEMBEDDED. Linked OLE Clients must have a valid source path.
So the Description OLE Client parts can use the popup connected to File, make the following connections:
Note: | An OLE Client part also provides attributes for making a Container menu (oleContainerMenuView) or a Window menu (oleWindowMenuView) available to an active embedded OLE client. |
The two connections to the popup menu must be in the correct order. To check the order, press mouse button 2 on the popup menu and, from its popup menu, select Reorder Connections From. In the Reorder connections window, ensure that the connection to the OLE Client part precedes the connection to the menu bar item. If it does not, drag it to the appropriate position using mouse button 1.
If you now test ClientRecordsView, you'll notice that pressing mouse button 2 on the Description OLE Client part displays the popup menu connected to File. Pressing mouse button 2 on the Bitmap OLE Client part displays a popup menu with options that open a graphic editor, provided you have a program such as Microsoft Paint on your system. Had you set sourcePath to a text file instead of a bitmap, then a text editor would have opened. This popup menu is the OLE verbs menu.
Next, make connections that enable you to access Windows applications by selecting menu choices on the two popup menus added to the free-form surface:
Note: | The restoreFromFile: and saveToFile: actions use instances of the class OleFile to retrieve or save OLE objects into OLE compound files. The OLE File part on the palette provides a more complete interface for manipulating OLE structured storage. |
When you finish, the Composition Editor shows: