Пример #1
0
 private void ResetPrevTarget()
 {
     if (m_LastTarget != null)
     {
         //ShowCnt("RSP Prior to LT.DragLeave")
         int hr = m_LastTarget.DragLeave();
         //ShowCnt("RSP After LT.DragLeave")
         Marshal.ReleaseComObject(m_LastTarget);
         //ShowCnt("RSP After Release of LT")
         m_LastTarget = null;
         m_LastNode   = null;
     }
 }
Пример #2
0
 private void ResetPrevTarget()
 {
     if (m_LastTarget != null)
     {
         //ShowCnt("RSP Prior to LT.DragLeave")
         int hr = m_LastTarget.DragLeave();
         //ShowCnt("RSP After LT.DragLeave")
         Marshal.ReleaseComObject(m_LastTarget);
         //ShowCnt("RSP After Release of LT")
         m_LastTarget = null;
         m_LastNode = null;
     }
 }
Пример #3
0
        //Private Sub ShowCnt(ByVal S As String)
        //    If Not IsNothing(m_DragData) Then
        //        Debug.WriteLine(S & " RefCnt = " & Marshal.AddRef(m_DragData) - 1)
        //        Marshal.Release(m_DragData)
        //    End If
        //End Sub
        public int DragOver(int grfKeyState, Point pt, ref int pdwEffect)
        {
            //Debug.WriteLine("In DragOver: Effect = " & pdwEffect & " Keystate = " & grfKeyState)

            TreeNode tn;
            System.Drawing.Point ptClient = m_View.PointToClient(new System.Drawing.Point(pt.X, pt.Y));
            tn = ((TreeView) m_View).GetNodeAt(ptClient);
            if (tn == null) //not over a TreeNode
            {
                ResetPrevTarget();
            }
            else //currently over Treenode
            {
                if (m_LastNode != null) //not the first, check if same
                {
                    if (tn == m_LastNode)
                    {
                        //Debug.WriteLine("DragOver: Same node")
                        return 0; //all set up anyhow
                    }
                    else
                    {
                        ResetPrevTarget();
                        m_LastNode = tn;
                    }
                }
                else //is the first
                {
                    ResetPrevTarget(); //just in case
                    m_LastNode = tn; //save current node
                }

                //Drag is now over a new node with new capabilities

                CShItem CSI = tn.Tag as CShItem;
                if (CSI.IsDropTarget)
                {
                    m_LastTarget = CSI.GetDropTargetOf(m_View) as ShellDll.IDropTarget;
                    if (m_LastTarget != null)
                    {
                        pdwEffect = m_Original_Effect;
                        //ShowCnt("Prior to LT.DragEnter")
                        int res = m_LastTarget.DragEnter(m_DragDataObj, grfKeyState, pt, ref pdwEffect);
                        if (res == 0)
                        {
                            //ShowCnt("Prior to LT.DragOver")
                            res = m_LastTarget.DragOver(grfKeyState, pt, ref pdwEffect);
                            //ShowCnt("After LT.DragOver")
                        }
                        if (res != 0)
                        {
                            Marshal.ThrowExceptionForHR(res);
                        }
                    }
                    else
                    {
                        pdwEffect = 0; //couldn't get IDropTarget, so report effect None
                    }
                }
                else
                {
                    pdwEffect = 0; //CSI not a drop target, so report effect None
                }
                if (ShDragOverEvent != null)
                    ShDragOverEvent(tn, ptClient, grfKeyState, pdwEffect);
            }
            return 0;
        }
Пример #4
0
        //Private Sub ShowCnt(ByVal S As String)
        //    If Not IsNothing(m_DragData) Then
        //        Debug.WriteLine(S & " RefCnt = " & Marshal.AddRef(m_DragData) - 1)
        //        Marshal.Release(m_DragData)
        //    End If
        //End Sub

        public int DragOver(int grfKeyState, Point pt, ref int pdwEffect)
        {
            //Debug.WriteLine("In DragOver: Effect = " & pdwEffect & " Keystate = " & grfKeyState)

            TreeNode tn;

            System.Drawing.Point ptClient = m_View.PointToClient(new System.Drawing.Point(pt.X, pt.Y));
            tn = ((TreeView)m_View).GetNodeAt(ptClient);
            if (tn == null)             //not over a TreeNode
            {
                ResetPrevTarget();
            }
            else                        //currently over Treenode
            {
                if (m_LastNode != null) //not the first, check if same
                {
                    if (tn == m_LastNode)
                    {
                        //Debug.WriteLine("DragOver: Same node")
                        return(0);                        //all set up anyhow
                    }
                    else
                    {
                        ResetPrevTarget();
                        m_LastNode = tn;
                    }
                }
                else                   //is the first
                {
                    ResetPrevTarget(); //just in case
                    m_LastNode = tn;   //save current node
                }

                //Drag is now over a new node with new capabilities

                CShItem CSI = tn.Tag as CShItem;
                if (CSI.IsDropTarget)
                {
                    m_LastTarget = CSI.GetDropTargetOf(m_View) as ShellDll.IDropTarget;
                    if (m_LastTarget != null)
                    {
                        pdwEffect = m_Original_Effect;
                        //ShowCnt("Prior to LT.DragEnter")
                        int res = m_LastTarget.DragEnter(m_DragDataObj, grfKeyState, pt, ref pdwEffect);
                        if (res == 0)
                        {
                            //ShowCnt("Prior to LT.DragOver")
                            res = m_LastTarget.DragOver(grfKeyState, pt, ref pdwEffect);
                            //ShowCnt("After LT.DragOver")
                        }
                        if (res != 0)
                        {
                            Marshal.ThrowExceptionForHR(res);
                        }
                    }
                    else
                    {
                        pdwEffect = 0;                         //couldn't get IDropTarget, so report effect None
                    }
                }
                else
                {
                    pdwEffect = 0;                     //CSI not a drop target, so report effect None
                }
                if (ShDragOverEvent != null)
                {
                    ShDragOverEvent(tn, ptClient, grfKeyState, pdwEffect);
                }
            }
            return(0);
        }