
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
hi, Mattias,Here is my interface declaration.
public enum CLIPFORMAT : uint
{
CF_TEXT = 1,
CF_BITMAP = 2,
CF_METAFILEPICT= 3,
CF_SYLK = 4,
CF_DIF = 5,
CF_TIFF = 6,
CF_OEMTEXT = 7,
CF_DIB = 8,
CF_PALETTE = 9,
CF_PENDATA = 10,
CF_RIFF = 11,
CF_WAVE = 12,
CF_UNICODETEXT= 13,
CF_ENHMETAFILE= 14,
CF_HDROP = 15,
CF_LOCALE = 16,
CF_MAX = 17,
CF_OWNERDISPLAY=0x0080,
CF_DSPTEXT = 0x0081,
CF_DSPBITMAP = 0x0082,
CF_DSPMETAFILEPICT= 0x0083,
CF_DSPENHMETAFILE = 0x008E,
CF_PRIVATEFIRST=0x0200,
CF_PRIVATELAST= 0x02FF,
CF_GDIOBJFIRST =0x0300,
CF_GDIOBJLAST = 0x03FF
}
public enum DVASPECT: uint
{
DVASPECT_CONTENT = 1,
DVASPECT_THUMBNAIL = 2,
DVASPECT_ICON = 4,
DVASPECT_DOCPRINT = 8
}
public enum TYMED: uint
{
TYMED_HGLOBAL = 1,
TYMED_FILE = 2,
TYMED_ISTREAM = 4,
TYMED_ISTORAGE= 8,
TYMED_GDI = 16,
TYMED_MFPICT = 32,
TYMED_ENHMF = 64,
TYMED_NULL= 0
}
[StructLayout(LayoutKind.Sequential)]
public struct FORMATETC
{
public uint cfFormat;
public uint ptd;
public DVASPECT dwAspect;
public int lindex;
public TYMED tymed;
}
[StructLayout(LayoutKind.Sequential)]
public struct STGMEDIUM
{
public uint tymed;
public uint hGlobal;
public uint pUnkForRelease;
}
[ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
GuidAttribute("0000010e-0000-0000-C000-000000000046")]
public interface IDataObject
{
[PreserveSig()]
int GetData(ref FORMATETC a, ref STGMEDIUM b);
[PreserveSig()]
void GetDataHere(int a, ref STGMEDIUM b);
[PreserveSig()]
int QueryGetData(ref FORMATETC f);
[PreserveSig()]
int GetCanonicalFormatEtc(int a, ref int b);
[PreserveSig()]
int SetData(int a, int b, int c);
[PreserveSig()]
int EnumFormatEtc(uint a, ref Object b);
[PreserveSig()]
int DAdvise(int a, uint b, Object c, ref uint d);
[PreserveSig()]
int DUnadvise(uint a);
[PreserveSig()]
int EnumDAdvise(ref Object a);
}
[ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
GuidAttribute("00000122-0000-0000-C000-000000000046")]
public interface IDropTarget
{
[PreserveSig()]
int DragEnter(object pDataObj, int grfKeyState, long pt, out int
pdwEffect);
[PreserveSig()]
int DragLeave();
[PreserveSig()]
int DragOver(int grfKeyState, long pt, out int pdwEffect);
[PreserveSig()]
int Drop(object pDataObj, int grfKeyState, long pt, out int pdwEffect);
}
[DllImport("ole32.dll")]
public static extern int OleLoadFromStream(UCOMIStream pStm,ref Guid
iidInterface,[MarshalAs(UnmanagedType.Interface)] out object ppvObj);
[DllImport("OLE32.DLL", EntryPoint="CreateStreamOnHGlobal")]
public static extern int CreateStreamOnHGlobal(int hGlobalMemHandle, bool
fDeleteOnRelease, out UCOMIStream pOutStm);
[DllImport("ole32.dll")]
public static extern int RegisterDragDrop(HandleRef hwnd, IDropTarget
target);
//public static extern int RegisterDragDrop(IntPtr hwnd, IDropTarget
target);
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true,
EntryPoint="RegisterClipboardFormatA")]
public static extern int RegisterClipboardFormat( string lpszFormat );
..
> How did you declare the IDropTarget interface?
>
> Mattias
Mattias Sj?gren - 20 Jul 2004 09:44 GMT
> [PreserveSig()]
> int DragEnter(object pDataObj, int grfKeyState, long pt, out int
>pdwEffect);
You should change the first parameter's type to IDataObject.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
SunStar - 20 Jul 2004 16:33 GMT
hi , Mattias
I tried to change the object to IDataObject, but the problem is still.
Regards
> > [PreserveSig()]
> > int DragEnter(object pDataObj, int grfKeyState, long pt, out int
[quoted text clipped - 3 lines]
>
> Mattias
Mattias Sj?gren - 23 Jul 2004 23:07 GMT
> I tried to change the object to IDataObject, but the problem is still.
Well I don't see anything else wrong with the DragEnter method, but
you have the same problem in Drop. Also, DragOver and DragLeave are in
the wrong order - DragOver should be declared first.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
SunStar - 24 Jul 2004 06:11 GMT
After I changed the order of declarations of dragover, dragleave , it works
now
Mattias, Thank you very much , You are the real guru :O)