Share via


How to: Implement IDataObject

Send Feedback

Shortcut menu extensions that target Office Mobile applications often process information in clipboard format. The following sample demonstrates code used by such a component.

Note   Object Identifiers (OIDs) in the pira parameter below, can be used in Pocket Outlook Object Model (POOM) API calls. These API members are declared in the header file Pimstore.h. You can get a handle to a POOM item by calling the IPOutlookApp::GetItemFromOid method. Using this reference as an entry point into the POOM, you can then call POOM APIs (for example, IContact::get_Birthday and ITask::get_StartDate).

For more information on IDataObject, see the Windows CE topic, IDataObject:IUnknown.

Code Example

The following code example demonstrates how to implement IDataObject.

Note   To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

#include "appext.h"   // To access ItemRef and ItemRefArray.

FORMATETC fmt;
STGMEDIUM stgmed;
ItemRefArray * pira;
CEOID oid;

fmt.cfFormat = RegisterClipboardFormat(CFNAME_ITEMREFARRAY);
fmt.lindex = -1;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.tymed = TYMED_HGLOBAL;

((IDataObject*)GetSite())->GetData(&fmt, &stgmed);
pira = (ItemRefArray*)stgmed->hGlobal;
oid = (CEOID)pira->rgRefs[0].pRef;

See Also

Menus | How to: Extend Shortcut Menus | How to: Implement IContextMenu and IObjectWithSite | How to: Register a File System Shortcut Menu | IDataObject:IUnknown | Shortcut Menu Overview

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.