FIX: HIERSVR Sample GetClipboardData() Parameters Incorrect

ID: Q117870

1.50 WINDOWS kbprg kbfixlist kbbuglist

The information in this article applies to:

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.

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 kbbuglist kbfixlist
Version           : 1.50
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: September 21, 1997