コード例 #1
0
        public static DragDropEffects CanDropClipboard(ShellItem item)
        {
            IntPtr dataObject;

            ShellAPI.OleGetClipboard(out dataObject);

            IntPtr targetPtr;

            Raccoom.Win32.IDropTarget target;

            DragDropEffects retVal = DragDropEffects.None;

            if (GetIDropTarget(item, out targetPtr, out target))
            {
                #region Check Copy
                DragDropEffects effects = DragDropEffects.Copy;
                if (target.DragEnter(
                        dataObject,
                        ShellAPI.MK.CONTROL,
                        new ShellAPI.POINT(0, 0),
                        ref effects) == ShellAPI.S_OK)
                {
                    if (effects == DragDropEffects.Copy)
                    {
                        retVal |= DragDropEffects.Copy;
                    }

                    target.DragLeave();
                }
                #endregion

                #region Check Move
                effects = DragDropEffects.Move;
                if (target.DragEnter(
                        dataObject,
                        ShellAPI.MK.SHIFT,
                        new ShellAPI.POINT(0, 0),
                        ref effects) == ShellAPI.S_OK)
                {
                    if (effects == DragDropEffects.Move)
                    {
                        retVal |= DragDropEffects.Move;
                    }

                    target.DragLeave();
                }
                #endregion

                #region Check Lick
                effects = DragDropEffects.Link;
                if (target.DragEnter(
                        dataObject,
                        ShellAPI.MK.ALT,
                        new ShellAPI.POINT(0, 0),
                        ref effects) == ShellAPI.S_OK)
                {
                    if (effects == DragDropEffects.Link)
                    {
                        retVal |= DragDropEffects.Link;
                    }

                    target.DragLeave();
                }
                #endregion

                Marshal.ReleaseComObject(target);
                Marshal.Release(targetPtr);
            }

            return(retVal);
        }