FORMATETC for IDataObject::DAdvise Must be Validated

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

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

SUMMARY

Applications implementing IDataObject must validate the FORMATETC structure that is passed to IDataObject::DAdvise(). Some commercial applications, such as Microsoft Excel 5.0, will try to set up an Advise on their own native format before setting up an Advise on the format selected by the user in the Paste Special dialog box while creating a link.

MORE INFORMATION

When validating the FORMATETC structure, the server application needs to allow wildcard Advises to succeed. A Wildcard Advise is an Advise set up by the default link object so that it can properly maintain the time-of-last- change. A Wildcard Advise is requested by passing a FORMATETC with cfFormat = 0, ptd = NULL, dwAspect = -1L, and tymed = -1L. Code to validate the FORMATETC structure might look as follows:

   // if not a Wildcard Advise and the data format is not supported,
   // return failure.

   if( !(pfmtetc->cfFormat == NULL  &&
         pfmtetc->ptd      == NULL  &&
         pfmtetc->dwAspect == -1L   &&
         pfmtetc->lindex   == -1L   &&
         pfmtetc->tymed    == -1L)
      && FAILED(hres = QueryGetData(pfmtetc)) )
      return hres;

   // Now pass on to the Data Advise holder

For more information on the IDataObject::DAdvise() member function, please refer to pages 436-439 of the "OLE Programmer's Reference, Volume 1".


Additional reference words: 2.01 3.50 4.00
KBCategory: kbole kbprg
KBSubcategory: LeTwoSvr


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.