AnimatGuiCtrls.Controls.ImageListDrag.DragDrop C# (CSharp) Method

DragDrop() public method

Shows the ImageList drag image at the current dragging position.
public DragDrop ( ) : void
return void
        public void DragDrop()
        {
            IntPtr hWndParent = IntPtr.Zero;
            Point dst = new Point();

            if (this.inDrag)
            {
                dst = Cursor.Position;
                if (this.owner != null)
                {
                    // Position relative to owner:
                    dst = this.owner.PointToClient(dst);
                }

                if (this.startDrag)
                {
                    this.hWndLast = (this.owner == null ? IntPtr.Zero : this.owner.Handle);
                    ImageList_DragEnter(
                        hWndLast,
                        dst.X, dst.Y);
                    this.startDrag = false;
                }

                ImageList_DragMove(dst.X, dst.Y);
            }
        }

Usage Example

        private void OnGiveFeedback(object sender, System.Windows.Forms.GiveFeedbackEventArgs args)
        {
            try
            {
                args.UseDefaultCursors = false;

                // Draw the drag image:
                // Debug.WriteLine("OnGiveFeedback: DraggingIcon: " + m_bDraggingIcon);
                if (m_bDraggingIcon)
                {
                    m_imageDrag.DragDrop();
                }
            }
            catch (System.Exception ex)
            { string strMsg = ex.Message; }
        }