Summary

In-place activation, also called visual editing, is a user interface extension of the embedding feature of OLE Documents. It provides a more document-centric computing model through a set of interfaces and protocols that a container and an embedded object use to merge their various user interface elements and display those elements in the container's frame and document windows directly. In this way, the user never leaves the document to work with content objects. Microsoft's usability tests have shown that end users work very well with this model.

Unlike a basic embedded object, which is activated in a separate window, an in-place–capable object literally creates a window inside a container's document. The object can provide adornments such as row and column headings that surround its editing space. But a window is not sufficient to provide all the facilities necessary for a user to work with the object, so the container and object work together to merge other user interface elements. This involves the creation of a shared menu on which items from both the container and the object are available, a negotiation process through which the object is granted space in the container to create toolbars and other frame window and document window adornments, a protocol for handling both the container and the object's accelerators, and a variety of other small concerns such as handling Undo operations, context-sensitive help, window resizing, window activation, status lines, and modeless pop-up windows.

To do all of this, a container implements the interface IOleInPlaceSite on its site object alongside IOleClientSite and IAdviseSink. The presence of IOleInPlaceSite marks the container as in-place capable. The container also creates objects that represent its frame and document (if applicable) windows, implementing the interfaces IOleInPlaceFrame and IOleInPlaceUIWindow. The object, on the other hand, implements IOleInPlaceObject to indicate its in-place support, and when activated in place, it provides an implementation of IOleInPlaceUIActiveObject. In-place activation is accomplished primarily by the communication between container and object through all these interfaces—OLE itself provides only message filtering and additional helper functions. This is one example in which rich integration is achieved directly between a client and a component with minimal overhead from the system.

In-place activation introduces two additional object states: in-place active and UI active. A UI-active object has full control over the user interface elements shared with the container, whereas an object that is only in-place active has a window in the container's document but nothing else. Many OLE controls fall into this latter category, and although only one object can be UI active at any given time, there can be any number of in-place–active objects. In addition, objects can mark themselves to become in-place active whenever they are visible or to indicate that they support a single-click activation model referred to as inside-out.

This chapter demonstrates the container side of in-place activation by adding support for this feature to the Patron sample. Patron works in conjunction with in-place–capable versions of Cosmo and Polyline, provided in Chapter 23.