Determining If an Object Is Capable of Visual Editing

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

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

SUMMARY

It is impossible for a container to consistently determine whether an object will attempt negotiation for visual editing. However, by determining whether the object supports the IOleInPlaceObject interface, the container may want to assume that the negotiation will occur.

The default object handler will always fail a call to QueryInterface for IOleInPlaceObject if the object is in the loaded state. The container must first run the object and then query for the IOleInPlaceObject interface. If this QueryInterface call succeeds, then the container can assume that the object supports visual editing, and may start negotiation on the execution of a verb.

MORE INFORMATION

The following C++ code returns TRUE if an object may start visual negotiation when IOleObject::DoVerb is called:

BOOL fCanInPlaceActivate(LPOLEOBJECT lpObject) { LPOLEINPLACEOBJECT lpInPlaceObject; BOOL retval;

    // Run the object.
    OleRun(lpObject);

    // Query for IOleInPlaceObject.
    HRESULT herr = lpObject->QueryInterface(IID_IOleInPlaceObject,
                                            (LPVOID FAR *)
                                            lpInPlaceObject);

    // Check the return value.
    if (herr == NOERROR)
        {
        retval = TRUE;
        lpInPlaceObject->Release();
        }
    else
        retval = FALSE;

    lpObject::Close(OLECLOSE_NOSAVE);

    return retval;
}


Additional reference words: 2.00 3.50 4.00
KBCategory: kbole kbprg kbcode
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.