Microsoft KB Archive/98678

= Containers Should Not Query for IOleInPlaceActiveObject =

Article ID: 98678

Article Last Modified on 3/3/2005

-

APPLIES TO

 Microsoft OLE 2.0 Microsoft OLE 4.0, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows NT 3.51 Service Pack 5

 Microsoft Windows NT 4.0

 Microsoft Windows 95</li></ul>

 Microsoft Windows 2000 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q98678

<div class="notice_section">

OLE (object linking and embedding) version 2.0 container applications should never call QueryInterface to get a pointer to the IOleInPlaceActiveObject interface. Instead, the container should AddRef the pointer passed to IOleInPlaceUIWindow::SetActiveObject and save it until needed.

Consider the scenario in which a nested object is currently inplace active; that is, the container contains an object and this contained object in turn holds another object that is inplace active. The container has a pointer only to the &quot;outer&quot; object, and is not aware of the &quot;inner&quot; object. Calling QueryInterface to get a pointer to IOleInPlaceActiveObject is meaningless on the outer object because the outer object is not currently inplace active. The only reliable way to get a pointer to the correct IOleInPlaceActiveObject interface is through IOleInPlaceUIWindow::SetActiveObject.

Objects capable of inplace activation should guard against this case, and never return IOleInPlaceActiveObject from QueryInterface.

Additional query words: 2.00 3.50 4.00

Keywords: kbinplaceact KB98678

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.