public int DragOver(ShellAPI.MK grfKeyState, ShellAPI.POINT pt, ref DragDropEffects pdwEffect) { bool reset = false; #region Get DropItem Point point = br.FileView.PointToClient(new Point(pt.x, pt.y)); ListViewHitTestInfo hitTest = br.FileView.HitTest(point); if (hitTest.Item != null && (br.FileView.View != View.Details || hitTest.SubItem == null || hitTest.Item.Name == hitTest.SubItem.Name) && (hitTest.Location == ListViewHitTestLocations.Image || hitTest.Location == ListViewHitTestLocations.Label || hitTest.Location == ListViewHitTestLocations.StateImage)) { if (!hitTest.Item.Equals(dropListItem)) { if (dropTarget != null) { dropTarget.DragLeave(); } ReleaseCom(); if (dropListItem != null) { dropListItem.Selected = wasSelected; } dropListItem = hitTest.Item; wasSelected = dropListItem.Selected; dropListItem.Selected = true; ShellItem item = (ShellItem)dropListItem.Tag; parentDropItem = item; ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget); reset = true; } } else { if (dropListItem != null) { if (dropTarget != null) { dropTarget.DragLeave(); } ReleaseCom(); dropListItem.Selected = wasSelected; dropListItem = null; parentDropItem = br.SelectedItem; ShellHelper.GetIDropTarget(br.SelectedItem, out dropTargetPtr, out dropTarget); reset = true; } } #endregion if (dropTarget != null) { if (reset) { dropTarget.DragEnter(dropDataObject, grfKeyState, pt, ref pdwEffect); } else { dropTarget.DragOver(grfKeyState, pt, ref pdwEffect); } } else { pdwEffect = DragDropEffects.None; } if (dropHelper != null) { dropHelper.DragOver(ref pt, pdwEffect); } return(ShellAPI.S_OK); }
public int DragOver(ShellAPI.MK grfKeyState, ShellAPI.POINT pt, ref DragDropEffects pdwEffect) { bool reset = false; #region Get DropItem Point point = br.FolderView.PointToClient(new Point(pt.x, pt.y)); TreeViewHitTestInfo hitTest = br.FolderView.HitTest(point); if (!TreeNode.Equals(dropNode, hitTest.Node)) { if (dropTarget != null) { dropTarget.DragLeave(); } ReleaseCom(); dropNode = hitTest.Node; br.FolderView.SelectedNode = dropNode; if (dropNode == null) { pdwEffect = DragDropEffects.None; if (dropHelper != null) { dropHelper.DragOver(ref pt, pdwEffect); } return(ShellAPI.S_OK); } else { ShellItem item = (ShellItem)dropNode.Tag; parentDropItem = item; ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget); reset = true; } } else if (dropNode == null) { if (dropTarget != null) { dropTarget.DragLeave(); } ReleaseCom(); dropNode = null; br.SelectedNode = null; pdwEffect = DragDropEffects.None; if (dropHelper != null) { dropHelper.DragOver(ref pt, pdwEffect); } return(ShellAPI.S_OK); } #endregion if (dropTarget != null) { if (reset) { dropTarget.DragEnter(dropDataObject, grfKeyState, pt, ref pdwEffect); } else { dropTarget.DragOver(grfKeyState, pt, ref pdwEffect); } } else { pdwEffect = DragDropEffects.None; } if (dropHelper != null) { dropHelper.DragOver(ref pt, pdwEffect); } return(ShellAPI.S_OK); }