Creating an OLE main window
OLE-enabled applications must use the OleMainWindow class rather than CwMainWindow. This is because OLE main windows can negotiate with OLE servers for menu-bar space and window real estate for in-place activation of any OLE object contained in its widget tree. An OleMainWindow is a subclass of CwMainWindow and, as such, it is created in the same way. The helper method createOleMainWindow: in CwWidget provides typical widget-creation protocol.
For example, a method of an OLE-enabled application that creates an OleMainWindow under a shell window might look like:
createMainWindow: shell
"Private - Create and answer the main window for the receiver."
createOleMainWindow: 'main'
argBlock: [:w | w hostName: 'Container']) manageChild
Here, the hostName resource is set even though it is often only used by non-in-place-activated OLE servers. In the case of non-in-place activation, the hostName may be displayed on the label of an OLE server's Close or Exit menu items. For example, given the hostName above, the label of an activated OLE server's normal termination menu item might read Exit to Container instead of simply Exit, as it would when the server application is explicitly launched. The menu bar of an OleMainWindow is partitioned into groups to facilitate the negotiation for menu-bar space during in-place activation. The groups are:
Each group contains one or more pull-down menus (CwCascadeButton widgets). During in-place activation, the container is asked to populate the File, Container, and Window groups with pull-down menus appropriate to those categories of function. After the container populates its groups, the server is asked to fill in the Edit, Object, and Help groups with pull-down menus appropriate for its editing operations.
A container's menu-bar negotiations with an OLE server are handled automatically by OleMainWindow. As a result, all you need do to facilitate these negotiations is provide the pull-down menus for any of the three groups it is interested in. OleMainWindow has the following instance methods for each designated menu group.
Each method takes an Array containing CwRowColumn widgets representing the menus for the group.
For example, the createMenuBar: method of an OLE container might have five pull-down menus defined for its normal operation and specify three of them for use when any contained OLE object is activated in place:
createMenuBar: mainWindow
"Private - Create and answer the menu bar for the receiver."
| menu children |
menu := mainWindow
createSimpleMenuBar: 'bar'
argBlock: [:w |
buttons: #('File' 'Edit' 'Container' 'Window' 'Help');
buttonMnemonics: #($F $E $C $W $H)].
children := menu children.
fileMenuGroup: (Array with: (children at: 1));
containerMenuGroup: (Array with: (children at: 3));
windowMenuGroup: (Array with: (children at: 4)).
menu manageChild.
During in-place activation, all other negotiations for window real estate (for example, tool-bar and status-bar space) between an OLE container and an OLE server are transparently handled by the OleMainWindow class. The menu group cannot be changed while an OLE client is active in place.
Last modified date: 01/29/2015