FIX: HIERSVR Sample GetClipboardData() Parameters Incorrect

Last reviewed: September 18, 1997
Article ID: Q117870
1.50 WINDOWS kbprg kbfixlist kbbuglist

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++ for Windows, version 1.5
    

SYMPTOMS

The HIERSVR sample for the MFC, version 2.5, incorrectly overrides the virtual function OnGetClipboardData()in its COleServerItem-derived class, CServerItem. This does not allow the sample to register its Clipboard format.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was fixed in MFC version 2.51, which is distributed with Visual C++, version 1.51.

MORE INFORMATION

The prototype for OnGetClipboardData in the base class is

   virtual COleDataSource*
         COleServerItem::OnGetClipboardData(BOOL bIncludeLink,
         LPPOINT pptOffset, LPSIZE pSize);

while the prototype in the derived class, CServerItem, is

   virtual COleDataSource*
         CServerItem::OnGetClipboardData(BOOL bIncludeLink,
         CPoint *pptOffset, CSize* pSize);

These functions have different function signatures, so the compiler views them as separate, overloaded functions. As a result, the framework always calls the base class version. In HIERSVR, this means that GetClipboardData() does not get called and the application's native Clipboard format is not posted to the Clipboard. The following steps demonstrate this problem and a workaround:

  1. Start HIERSVR

  2. Choose Edit from the Copy menu to copy an object to the Clipboard.

  3. Start the OLE 2.01 toolkit, IDataObject viewer.

  4. Choose Clipboard from Get Clipboard Object.
  • The formats posted to the Clipboard include CF_TEXT, CF_METAFILEPICT, Embed Source, and Object Descriptor.

    1. Change the function CServerItem:;OnGetClipboardData to match the prototype of the base class,COleServerItem::OnGetClipboardData, so that the parameters are instead BOOL bIncludeLink, LPPOINT pptOffset, LPSIZE pSize.

    2. Rebuild HIERSVR, and repeat steps 1 through 4. The Clipboard formats should now include "MFC 2.5 Hiersvr Sample".


  • Additional reference words: 1.50 2.50
    KBCategory: kbprg kbfixlist kbbuglist
    KBSubcategory: MfcMisc
    Keywords : kb16bitonly MfcMisc kbbuglist kbfixlist kbprg
    Technology : kbMfc
    Version : 1.50
    Platform : WINDOWS
    Solution Type : kbfix


    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: September 18, 1997
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.