Muokkaa

Jaa


Menus and Resources: Container Additions

This article explains the changes that need to be made to the menus and other resources in a visual editing container application.

In container applications, two types of changes need to be made: modifications to existing resources to support OLE visual editing and addition of new resources used for in-place activation. If you use the application wizard to create your container application, these steps will be done for you, but they may require some customization.

If you do not use the application wizard, you may want to look at OCLIENT.RC, the resource script for the OCLIENT sample application, to see how these changes are implemented. See the MFC OLE sample OCLIENT.

Topics covered in this article include:

Container Menu Additions

You must add the following items to the Edit menu:

Item Purpose
Insert New Object Opens the OLE Insert Object dialog box to insert a linked or embedded item into the document.
Paste Link Pastes a link to the item on the Clipboard into the document.
OLE Verb Calls the selected item's primary verb. The text of this menu item changes to reflect the primary verb of the selected item.
Links Opens the OLE Edit Links dialog box to change existing linked items.

In addition to the changes listed in this article, your source file must include AFXOLECL.RC, which is required for the Microsoft Foundation Class Library implementation. Insert New Object is the only required menu addition. Other items can be added, but those listed here are the most common.

You must create a new menu for your container application if you want to support in-place activation of contained items. This menu consists of the same File menu and Window pop-up menus used when files are open, but it has two separators placed between them. These separators are used to indicate where the server (component) item (application) should place its menus when activated in place. For more information on this menu-merging technique, see Menus and Resources: Menu Merging.

Container Application Accelerator Table Additions

Small changes to a container application's accelerator table resources are necessary if you are supporting in-place activation. The first change allows the user to press the escape key (ESC) to cancel the in-place editing mode. Add the following entry to the main accelerator table:

ID Key Type
ID_CANCEL_EDIT_CNTR VK_ESCAPE VIRTKEY

The second change is to create a new accelerator table that corresponds to the new menu resource created for in-place activation. This table has entries for the File and Window menus in addition to the VK_ESCAPE entry above. The following example is the accelerator table created for in-place activation in the MFC sample CONTAINER:

ID Key Type
ID_FILE_NEW CTRL+N VIRTKEY
ID_FILE_OPEN CTRL+O VIRTKEY
ID_FILE_SAVE CTRL+S VIRTKEY
ID_FILE_PRINT CTRL+P VIRTKEY
ID_NEXT_PANE VK_F6 VIRTKEY
ID_PREV_PANE SHIFT+VK_F6 VIRTKEY
ID_CANCEL_EDIT_CNTR VK_ESCAPE VIRTKEY

String Table Additions for Container Applications

Most of the changes to string tables for container applications correspond to the additional menu items mentioned in Container Menu Additions. They supply the text displayed in the status bar when each menu item is displayed. As an example, here are the string-table entries the application wizard generates:

ID String
IDP_OLE_INIT_FAILED OLE initialization failed. Make sure that the OLE libraries are the correct version.
IDP_FAILED_TO_CREATE Failed to create object. Make sure that the object is entered in the system registry.

See also

Menus and Resources (OLE)
Menus and Resources: Server Additions