Esempio n. 1
0
        private void tv1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
        {
            //Primary (internal) data type
            ArrayList toDrag = new ArrayList();
            CShItem   csi    = ((TreeNode)e.Item).Tag as CShItem;

            toDrag.Add(csi);
            //also need Shell IDList Array
            System.IO.MemoryStream MS;
            MS = CProcDataObject.MakeShellIDArray(toDrag);
            //Fairly universal data type (must be an array)
            string[] strD = new string[1];
            strD[0] = csi.Path;
            //Build data to drag
            DataObject dataObj = new DataObject();

            dataObj.SetData(toDrag);
            if (MS != null)
            {
                dataObj.SetData("Shell IDList Array", true, MS);
            }
            dataObj.SetData("FileDrop", true, strD);
            //Do drag, allowing Copy and Move
            DragDropEffects ddeff;

            ddeff = tv1.DoDragDrop(dataObj, DragDropEffects.Copy | DragDropEffects.Move);
            //the following line commented out, since we can't depend on ddeff
            //If ddeff = DragDropEffects.None Then Exit Sub 'nothing happened
            RefreshNode(FindAncestorNode(csi));
        }
Esempio n. 2
0
        public int DragLeave()
        {
            //Debug.WriteLine("In DragLeave")
            m_Original_Effect = 0;
            ResetPrevTarget();
            int cnt = Marshal.Release(m_DragDataObj);

            Debug.WriteLine("DragLeave: cnt = " + cnt);
            m_DragDataObj      = IntPtr.Zero;
            m_OriginalRefCount = 0;             //just in case
            m_MyDataObject     = null;
            if (ShDragLeaveEvent != null)
            {
                ShDragLeaveEvent();
            }
            return(0);
        }
Esempio n. 3
0
        public int DragEnter(IntPtr pDataObj, int grfKeyState, Point pt, ref int pdwEffect)
        {
            Debug.WriteLine("In DragEnter: Effect = " + pdwEffect + " Keystate = " + grfKeyState);
            m_Original_Effect  = pdwEffect;
            m_DragDataObj      = pDataObj;
            m_OriginalRefCount = Marshal.AddRef(m_DragDataObj);             //note: includes our count
            Debug.WriteLine("DragEnter: pDataObj RefCnt = " + m_OriginalRefCount);

            m_MyDataObject = new CProcDataObject(pDataObj);

            if (m_MyDataObject.IsValid)
            {
                m_DropList = m_MyDataObject.DragList;
                if (ShDragEnterEvent != null)
                {
                    ShDragEnterEvent(m_DropList, pDataObj, grfKeyState, pdwEffect);
                }
            }
            else
            {
                pdwEffect = (int)System.Windows.Forms.DragDropEffects.None;
            }
            return(0);
        }
Esempio n. 4
0
 public int DragLeave()
 {
     //Debug.WriteLine("In DragLeave")
     m_Original_Effect = 0;
     ResetPrevTarget();
     int cnt = Marshal.Release(m_DragDataObj);
     Debug.WriteLine("DragLeave: cnt = " + cnt);
     m_DragDataObj = IntPtr.Zero;
     m_OriginalRefCount = 0; //just in case
     m_MyDataObject = null;
     if (ShDragLeaveEvent != null)
         ShDragLeaveEvent();
     return 0;
 }
Esempio n. 5
0
        public int DragEnter(IntPtr pDataObj, int grfKeyState, Point pt, ref int pdwEffect)
        {
            Debug.WriteLine("In DragEnter: Effect = " + pdwEffect + " Keystate = " + grfKeyState);
            m_Original_Effect = pdwEffect;
            m_DragDataObj = pDataObj;
            m_OriginalRefCount = Marshal.AddRef(m_DragDataObj); //note: includes our count
            Debug.WriteLine("DragEnter: pDataObj RefCnt = " + m_OriginalRefCount);

            m_MyDataObject = new CProcDataObject(pDataObj);

            if (m_MyDataObject.IsValid)
            {
                m_DropList = m_MyDataObject.DragList;
                if (ShDragEnterEvent != null)
                    ShDragEnterEvent(m_DropList, pDataObj, grfKeyState, pdwEffect);
            }
            else
            {
                pdwEffect = (int)System.Windows.Forms.DragDropEffects.None;
            }
            return 0;
        }