Containers Should Not Query for IOleInPlaceActiveObject

Last reviewed: May 17, 1995
Article ID: Q98678
The information in this article applies to:
  • Microsoft OLE Libraries for Windows and Win32s, version 2.0
  • Microsoft OLE Libraries, included with:

        - Microsoft Windows NT, versions 3.5 and 3.51
        - Microsoft Windows 95
    

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 "outer" object, and is not aware of the "inner" 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 reference words: 2.00 3.50 4.00
KBCategory: kbole kbprg
KBSubcategory: LeTwoInp


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.