## FIX: HIERSVR Sample GetClipboardData() Parameters Incorrect

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.

    5. 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.

    6. 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 kbnokeyword kbMFC kbVC
Issue type :
Technology : kbAudDeveloper kbMFC

Last Reviewed: May 5, 2001 © 2001 Microsoft Corporation. All rights reserved. Terms of Use.