Containers: Advanced Features

HomeOverviewHow Do ISampleTutorial

This article describes the steps necessary to incorporate optional advanced features into existing container applications. These features are:

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 can’t create a combination container/mini-server 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, you’ll need to perform some of those same tasks, adding code to the container. The following lists the important things to consider:

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 AppWizard 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.

Links to Embedded Objects

The Links to Embedded Objects feature enables a user to create a document with an OLE link to an embedded object inside your container application. For example, create a document in a word processor containing an embedded spreadsheet. If your application supports links to embedded objects, it could paste a link to the spreadsheet contained in the word processor’s document. This feature allows your application to use the information contained in the spreadsheet without knowing where the word processor originally got it.

To link to embedded objects in your application

  1. Derive your document class from COleLinkingDoc instead of COleDocument.

  2. Create an OLE class ID (CLSID) for your application by using the Class ID Generator included with the OLE Development Tools.

  3. Register the application with OLE.

  4. Create a COleTemplateServer object as a member of your application class.

  5. In your application class’s InitInstance member function, do the following:

The MFC OLE sample OCLIENT implements this feature. For an example of how this is done, see the InitInstance function in the OCLIENT.CPP file of this sample application.

See Also   Servers