Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "IDataObject" in [All]

Interfaces

.
Summary
The IDataObject interface is used by the Clipboard class and in drag-and-drop operations.
.

public interface IDataObject

.
Documentation
[IDataObject] on MSDN
.

        [In, MarshalAs(UnmanagedType.Interface)] IDataObject dataObject);

.

        [In, MarshalAs(UnmanagedType.Interface)] IDataObject dataObject);

.

    using IDataObject_Com = System.Runtime.InteropServices.ComTypes.IDataObject;

.

    void DragEnter([In] IntPtr hwndTarget, [In, MarshalAs(UnmanagedType.Interface)] IDataObject_Com dataObject, [In] ref drawing.Point pt, [In] DragDropEffects effect);

.

    void Drop([In, MarshalAs(UnmanagedType.Interface)] IDataObject_Com dataObject, [In] ref drawing.Point pt, [In] DragDropEffects effect);

.

        dropHelper.DragEnter(hWnd, e.Data as IDataObject_Com, ref point, e.Effects);

.

        dropHelper.Drop(e.Data as IDataObject_Com, ref point, e.Effects);

.

     void InitFromData(IDataObject pDataObject, bool fCreation, uint dwReserved);

.

     void GetClipboardData(uint dwReserved, ref IDataObject ppDataObject);

.

  void GetClipboardData(ref CHARRANGE lpchrg, [MarshalAs(UnmanagedType.U4)] GetClipboardDataFlags reco, out IDataObject lplpdataobj);

.

  void ImportDataObject(IDataObject lpdataobj, int cf, IntPtr hMetaPict);

user32

.

                    IDataObject dataObject = (IDataObject)Marshal.GetObjectForIUnknown(lpdobj);

ole32

.

static extern int DoDragDrop(IDataObject pDataObject, IDropSource pDropSource,

. . .

static extern int OleGetClipboard(out IDataObject ppDataObj);

.

The original signature requires a definition for the COM version of IDataObject, as defined in objidl.h. The lack of this definition implies that the [System.Windows.Forms.IDataObject] interface can be used, but this interface, although COM-visible, is not the same as the COM one and results in a [System.InvalidCastException].

.

The alternative posted uses an object, which can then be passed to a [System.Windows.Forms.DataObject] ctor. Ideally though there should be a complete definition for the COM [IDataObject] interface (and all of its supporting types).

.

[DllImport("ole32.dll")] static extern int OleIsCurrentClipboard(IDataObject pDataObject);

.

static extern int OleSetClipboard(IDataObject pDataObj);

.

Public Shared Function OleSetClipboard(ByVal pDataObj As System.Runtime.InteropServices.ComTypes.IDataObject) As Int32


 
Access PInvoke.net directly from VS: