A server application shows different menus, depending on whether it is running stand-alone, embedded, or in-place activated. AppWizard provides three different menus for these cases:
IDR_SCRIBBTYPE
is the menu for the document when it is opened in the usual way.IDR_SCRIBBTYPE_SRVR_EMB
is the menu for the document when the server is opened fully from the container application.IDR_SCRIBBTYPE_SRVR_IP
is the menu for the document when it is activated in place (thus, “IP”) in a container. When an object is activated in place, OLE merges the menu of the container application with the menu provided by the server application. The merging of the two menus is based on separator bars. Scribble’s in-place menu (IDR_SCRIBBTYPE_SRVR_IP
) looks like this:Edit | Pen | Help
An example of a container’s menu is seen in Container (the ActiveX Container tutorial discussed in Lessons 13 through 15), as shown below:
File | | Window
OLE merges the two menus to create the following menu when the Scribble object is activated in place in the Container application. By doing so, you can perform any Scribble-related tasks from within the container.
File Edit Pen Window Help
OLE merges pop-up menus, from left to right, in the following order:
Scribble’s two distinct OLE-related menu resources are referred to in Scribble.cpp in CScribbleApp::InitInstance
:
pDocTemplate->SetServerInfo(
IDR_SCRIBBTYPE_SRVR_EMB, IDR_SCRIBBTYPE_SRVR_IP,
RUNTIME_CLASS(CInPlaceFrame));
AppWizard provides all the code and resources described above, except for the Pen pop-up menu, which is application specific. If you are creating a new application from scratch, each new pop-up menu must be added to each of the three resources. This is easy to do with the drag and copy feature of the Menu editor. You can copy a resource by dragging it to the desired location while holding down the CTRL key and then releasing the mouse button.
In this part of the tutorial, you will:
IDR_SCRIBBTYPE_SRVR_EMB
and IDR_SCRIBBTYPE_SRVR_IP
, from the AppWizard-provided Scratch\Scribble.rc to your Scribble.rc.To copy menu resources
IDR_SCRIBBTYPE_SRVR_EMB
and IDR_SCRIBBTYPE_SRVR_IP
from the scratch resource file to your Scribble project .RC file.To copy menu items
IDR_SCRIBBTYPE
and IDR_SCRIBBTYPE_SRVR_EMB
in your Scribble project resource file.IDR_SCRIBBTYPE
into the IDR_SCRIBBTYPE_SRVR_EMB
menu so that it is between the Edit and View menus, as in IDR_SCRIBBTYPE
.IDR_SCRIBBTYPE
to the Edit menu in IDR_SCRIBBTYPE_SRVR_EMB
.IDR_SCRIBBTYPE_SRVR_EMB
and repeat steps 1 to 3 for IDR_SCRIBBTYPE_SRVR_IP
, placing the Pen menu as follows:Edit | Pen | View | | | | Help
(Don’t copy the Clear All menu item.)