
Creating a Container/Server Application
A container/server application is an application that acts as both a container and a server. Microsoft Word for Windows is an example of this. You can embed Word for Windows documents in other applications, and you can also embed items in Word for Windows documents. The process for modifying your container application to be both a container and a full server (you cannot create a combination container/miniserver application) is similar to the process for creating a full server.
The article Servers: Implementing a Server lists a number of tasks required to implement a server application. If you convert a container application to a container/server application, then you need to perform some of those same tasks, adding code to the container. The following lists the important things to consider:
The container code created by the application wizard already initializes the OLE subsystem. You will not need to change or add anything for that support.
Wherever the base class of a document class is COleDocument, change the base class to COleServerDoc.
Override COleClientItem::CanActivate to avoid editing items in place while the server itself is being used to edit in place.
For example, the MFC OLE sample OCLIENT has embedded an item created by your container/server application. You open the OCLIENT application and in-place edit the item created by your container/server application. While editing your application's item, you decide you want to embed an item created by the MFC OLE sample HIERSVR. To do this, you cannot use in-place activation. You must fully open HIERSVR to activate this item. Because the Microsoft Foundation Class Library does not support this OLE feature, overriding COleClientItem::CanActivate allows you to check for this situation and prevent a possible run-time error in your application.
If you are creating a new application and want it to function as a container/server application, choose that option in the OLE Options dialog box in the application wizard and this support will be created automatically. For more information, see the article Overview: Creating an ActiveX Control Container. For information about MFC samples, see MFC Samples.
Note that you cannot insert an MDI application into itself. An application that is a container/server cannot be inserted into itself unless it is an SDI application.