# IOleInPlaceUIWindow::SetActiveObject

Provides a direct channel of communication between the object and each of the frame and document windows.

HRESULT SetActiveObject(

IOleInPlaceActiveObject *pActiveObject, | //Pointer to active in-place object
LPCOLESTR pszObjName | //Pointer tostring containing a name describing the object
); |

Parameters

pActiveObject
  [in] Pointer to the IOleInPlaceActiveObject interface on the active in-place object.
pszObjName
  [in] Pointer to a string containing a name that describes the object an embedding container can use in composing its window title. It can be NULL if the object does not require the container to change its window titles. The Microsoft Windows User Interface Design Guide recommends that containers ignore this parameter and always use their own name in the title bar.

Return Values

This method supports the standard return values E_INVALIDARG and E_UNEXPECTED, as well as the following:

S_OK
  The method completed successfully.

Remarks

Generally, an embedded object should pass NULL for the pszObjName parameter (see “Notes to Implementers” below). However, if you are working in conjunction with a container that does display the name of the in-place active object in its title bar, then you should compose a string in the following form:

<application name> <object short-type name>

#### Notes to Callers

IOleInPlaceUIWindow::SetActiveObject is called by the object to establish a direct communication link between itself and the document and frame windows.

When deactivating, the object calls IOleInPlaceUIWindow::SetActiveObject, passing NULL for the pActiveObject and pszObjName parameters.

An object must call IOleInPlaceUIWindow::SetActiveObject before calling IOleInPlaceFrame::SetMenu to give the container the pointer to the active object. The container then uses this pointer in processing IOleInPlaceFrame::SetMenu and to pass to OleSetMenuDescriptor.

#### Notes to Implementers

The Microsoft Windows User Interface Design Guide recommends that an in-place container ignore the pszObjName parameter passed in this method. The guide says “The title bar is not affected by in-place activation. It always displays the top-level container’s name.”

See Also

IOleInPlaceFrame::SetMenu, OleSetMenuDescriptor