Home | Overview | How Do I | Sample | Tutorial
This article explains the changes that need to be made to the menus and other resources in a visual editing server (component) application. A server application requires many additions to the menu structure and other resources because it can be started in one of three modes: stand-alone, embedded, or in place. As described in the Menus and Resources (OLE) article, there are a maximum of four sets of menus. All four are used for an MDI full-server application, while only three are used for a mini-server. AppWizard will create the menu layout necessary for the type of server you want. Some customization may be necessary.
If you don’t use AppWizard, you may want to look at HIERSVR.RC, the resource script for the MFC sample application HIERSVR, to see how these changes are implemented.
Topics covered in this article include:
Server (component) applications must have menu resources added to support OLE visual editing. The menus used when the application is run in stand-alone mode do not have to be changed, but you must add two new menu resources before building the application; one to support in-place activation and one to support the server being fully open. Both menu resources are used by full- and mini-server applications.
In addition to the changes listed in this article, your resource file needs to include AFXOLESV.RC, which is required for the Microsoft Foundation Class Library implementation. This file is in the MFC\Include subdirectory.
Two new accelerator table resources must be added to server applications; they correspond directly to the new menu resources described above. The first accelerator table is used when the server application is activated in place. It consists of all the entries in the view’s accelerator table except those tied to the File and Window menus.
The second table is nearly an exact copy of the view’s accelerator table. Any differences parallel changes made in the fully open menu mentioned in Server Menu Additions.
For an example of these accelerator table changes, compare the IDR_HIERSVRTYPE_SRVR_IP and IDR_HIERSVRTYPE_SRVR_EMB accelerator tables with IDR_MAINFRAME in the HIERSVR.RC file included in the MFC OLE sample HIERSVR. The File and Window accelerators are missing from the in-place table and exact copies of them are in the embedded table.
Only one string table addition is necessary in a server application — a string to signify that the OLE initialization failed. As an example, here is the string-table entry AppWizard generates:
ID | String |
IDP_OLE_INIT_FAILED | OLE initialization failed. Make sure that the OLE libraries are the correct version. |
The same additions apply for mini-servers as those listed above for full-servers. Because a mini-server can’t be run in stand-alone mode, its main menu is much smaller. The main menu created by AppWizard has only a File menu, containing only the items Exit and About. Embedded and in-place menus and accelerators for mini-servers are exactly the same as those for full-servers.
See Also Menus and Resources: Menu Merging