IOleInPlaceSite interface

The container-side site for in-place activation: a container learns through it when its object is activated and deactivated, and gives the object the windows and rectangles it needs.

IOleInPlaceSite has the interface identifier 00000119-0000-0000-C000-000000000046 and extends IOleWindow, so it also has that interface’s GetWindow and ContextSensitiveHelp methods. It is declared [OleAutomation(False)]. Microsoft Learn describes the Windows interface: IOleInPlaceSite.

The declaration is complete: it has all ten methods of the Windows interface. CanInPlaceActivate is marked [PreserveSig], so a class cannot implement this interface; it is for calling. The other nine hide the HRESULT: a failure code raises a run-time error.

A parameter that is a pointer to a structure (a RECT*, an OLEINPLACEFRAMEINFO*) is a LongPtr: pass the address of an OLERECT or an OLEINPLACEFRAMEINFO with VarPtr.

Methods

CanInPlaceActivate

[PreserveSig]
Function CanInPlaceActivate() As Long

Asks whether the container can activate the object in place. The result is the raw HRESULT: S_OK (0) when it can and S_FALSE (1) when it cannot.

OnInPlaceActivate

Sub OnInPlaceActivate()

Tells the container that its object is about to be activated in place.

OnUIActivate

Sub OnUIActivate()

Tells the container that the object is about to replace the container’s menus and toolbars with its own.

GetWindowContext

Sub GetWindowContext(ByRef ppFrame As OLEGuids.IOleInPlaceFrame, ByRef ppDoc As OLEGuids.IOleInPlaceUIWindow, ByVal lprcPosRect As LongPtr, ByVal lprcClipRect As LongPtr, ByVal lpFrameInfo As LongPtr)

Returns what the object needs to run in place. ppFrame receives the container’s IOleInPlaceFrame, and ppDoc its document window’s IOleInPlaceUIWindow, or Nothing when the document window is the frame window. The container writes the object’s position in its parent window to the RECT that lprcPosRect points to, and the outer clipping rectangle to the one that lprcClipRect points to. It fills the OLEINPLACEFRAMEINFO that lpFrameInfo points to.

Scroll

Sub Scroll(ByVal scrollExtant As Currency)

Asks the container to scroll the object by a number of pixels. The Windows method takes a SIZE by value, the distances in the x and y directions. This declaration passes the same eight bytes as a Currency. After the scroll, the container gives the object the new clipping rectangle with IOleInPlaceObject.SetObjectRects.

OnUIDeactivate

Sub OnUIDeactivate(ByVal fUndoable As Long)

Tells the container that the object deactivated its user interface, so the container restores its own menus and toolbars. fUndoable is not 0 when the object can undo the changes made since it was activated.

OnInPlaceDeactivate

Sub OnInPlaceDeactivate()

Tells the container that the object is no longer active in place.

DiscardUndoState

Sub DiscardUndoState()

Tells the container to discard the undo state that the object kept for ReactivateAndUndo, because the object can no longer undo.

DeactivateAndUndo

Sub DeactivateAndUndo()

Asks the container to deactivate the object and return it to the state it had before it was activated.

OnPosRectChange

Sub OnPosRectChange(ByVal lprcPosRect As LongPtr)

Tells the container that the object’s position changed. lprcPosRect points to a RECT holding the new position.

See Also