In-Place Interfaces for Objects

The presence of IOleInPlaceObject marks an object as in-place capable. Otherwise, an in-place–capable object appears to a container as any other embedded object does. This interface is always available through QueryInterface with any of the object's other interfaces. When an object becomes in-place active, it also provides an implementation of IOleInPlaceActiveObject, which is conceptually located on a separate object altogether, as shown in Figure 22-2. Typically, as we'll see in Chapter 23, this interface is implemented on the object itself, but with a QueryInterface that doesn't respond to any interfaces other than IUnknown and IOleInPlaceActiveObject.

Figure 22-2.

The structure of an in-place–capable object.

As with the container interfaces, both IOleInPlaceObject and IOleInPlaceActiveObject are derived from IOleWindow, as shown in the code on the following page.


interface IOleInPlaceObject : IOleWindow
{
HRESULT InPlaceDeactivate(void);
HRESULT UIDeactivate(void);
HRESULT SetObjectRects(LPCRECT prcPosRect, LPCRECT prcClipRect);
HRESULT ReactivateAndUndo(void);
};

interface IOleInPlaceActiveObject : IOleWindow
{
HRESULT TranslateAccelerator(LPMSG pMsg);
HRESULT OnFrameWindowActivate(BOOL fActivate);
HRESULT OnDocWindowActivate(BOOL fActivate);
HRESULT ResizeBorder(LPCRECT prcBorder
, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow);
HRESULT EnableModeless(BOOL fEnable);
};

For the most part, these interfaces consist of various notifications that the container will send to the object when important things happen in the user interface. These events include deactivation of the object, resizing the object, performing an Undo operation, detecting a keyboard accelerator, changing window activation, resizing a window, and displaying or removing some sort of modal window.