Hello,
Im trying to fetch a Drop-event, and everything goes fine until I call the
"GetData" method.
Ive tried both to catch the drop with defining FormatEtc to a CF_HDROP and
iterating Formats with "EnumFormatEtc" both returns same error...
Im guessing it doesnt like the input of FormatEtc or StgMedium params but
have compared my input with other working C++ code and I cant see any diff.
here are my definitions:
[ComVisible(false), StructLayout(LayoutKind.Sequential)]
public struct StgMedium {
[MarshalAs(UnmanagedType.U4)]
public StorageMedia tymed;
public IntPtr p;
[MarshalAs(UnmanagedType.IUnknown)]
public IntPtr pUnkForRelease;
}
[ComVisible(false), StructLayout(LayoutKind.Sequential)]
public struct FormatEtc {
[MarshalAs(UnmanagedType.I4)]
public int cfFormat;
public IntPtr ptd;
[MarshalAs(UnmanagedType.U4)]
public DeviceAspects dwAspect;
[MarshalAs(UnmanagedType.I4)]
public int lindex;
[MarshalAs(UnmanagedType.U4)]
public StorageMedia tymed;
}
and the IDataObject::GetData method:
[PreserveSig]
int GetData([In]ref FormatEtc pformatetcIn, [In, Out] ref StgMedium
pmedium);
and one of the calls:
----------------------
FormatEtc formatetc = new FormatEtc();
formatetc.cfFormat = (int)Shell32.CF_HDROP;
formatetc.ptd = IntPtr.Zero;
formatetc.dwAspect = DeviceAspects.Content;
formatetc.lindex = -1;
formatetc.tymed = StorageMedia.HGlobal;
StgMedium stgMedium = new StgMedium();
pDataObj.GetData(ref formatetc, ref stgMedium);
Anyone?
//DH
Michael Phillips, Jr. - 06 Jul 2006 14:47 GMT
> [PreserveSig]
> int GetData([In]ref FormatEtc pformatetcIn, [In, Out] ref StgMedium
> pmedium);
StgMedium is an Out parameter. It is allocated by the callee not the
caller.
Try this:
[PreserveSig]
int GetData([In]ref FormatEtc pformatetcIn, [Out] out StgMedium pmedium);
StgMedium stgMedium;
pDataObj.GetData(ref formatetc, out stgMedium);
> Hello,
>
[quoted text clipped - 55 lines]
>
> //DH