public int DragOver(int grfKeyState, Point pt, ref DragDropEffects pdwEffect) { if (pt != pointLastDrag) { pointLastDrag = pt; parent.OnDragOver(pt); } return(passthrough.DragOver(grfKeyState, pt, ref pdwEffect)); }
public int DragDrop(System.Runtime.InteropServices.ComTypes.IDataObject pDataObj, int grfKeyState, BandObjectLib.POINT pt, ref DragDropEffects pdwEffect) { try { if (this.DragFileOver != null) { DragEventArgs e = new DragEventArgs(null, grfKeyState, pt.x, pt.y, DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll, pdwEffect); this.DragFileOver(null, e); pdwEffect = e.Effect; } else { pdwEffect = DragDropEffects.Copy; } if (pdwEffect != DragDropEffects.None) { if (this.DragFileDrop != null) { IntPtr ptr; byte[] buffer; switch (this.DragFileDrop(out ptr, out buffer)) { case -1: return(0); case 0: { IShellFolder ppv = null; object obj2 = null; Guid riid = ExplorerGUIDs.IID_IShellFolder; Guid guid2 = ExplorerGUIDs.IID_IDropTarget; using (IDLWrapper wrapper = new IDLWrapper(buffer)) { if (wrapper.Available && wrapper.IsDropTarget) { try { IntPtr ptr2; if (PInvoke.SHBindToParent(wrapper.PIDL, riid, out ppv, out ptr2) == 0) { uint rgfReserved = 0; IntPtr[] apidl = new IntPtr[] { ptr2 }; if (ppv.GetUIObjectOf(ptr, 1, apidl, ref guid2, ref rgfReserved, out obj2) == 0) { _IDropTarget target = obj2 as _IDropTarget; if (target != null) { DragDropEffects effects = pdwEffect; if (target.DragEnter(pDataObj, this.iLastKeyState, pt, ref effects) == 0) { effects = pdwEffect; if (target.DragOver(this.iLastKeyState, pt, ref effects) == 0) { if ((this.iLastKeyState & 2) != 0) { pdwEffect = DragDropEffects.Link | DragDropEffects.Move | DragDropEffects.Copy; } return(target.DragDrop(pDataObj, this.iLastKeyState, pt, ref pdwEffect)); } } } } } } catch { } finally { if (ppv != null) { Marshal.ReleaseComObject(ppv); } if (obj2 != null) { Marshal.ReleaseComObject(obj2); } if (this.DragDropEnd != null) { this.DragDropEnd(this, EventArgs.Empty); } } } } return(0); } } } FORMATETC format = new FORMATETC(); format.cfFormat = 15; format.ptd = IntPtr.Zero; format.dwAspect = DVASPECT.DVASPECT_CONTENT; format.lindex = -1; format.tymed = TYMED.TYMED_HGLOBAL; STGMEDIUM medium = new STGMEDIUM(); try { pDataObj.GetData(ref format, out medium); PInvoke.SendMessage(this.hwnd, 0x233, medium.unionmember, IntPtr.Zero); } catch { } finally { PInvoke.ReleaseStgMedium(ref medium); } } } finally { if (pDataObj != null) { Marshal.FinalReleaseComObject(pDataObj); } } return(0); }