dragging large icons in a listview ( like windows explorer )-VBForums
Results 1 to 1 of 1

Thread: dragging large icons in a listview ( like windows explorer )

  1. #1

    Thread Starter
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,140

    Post dragging large icons in a listview ( like windows explorer )

    I've built a little example which allows you to drag listview items around ( in large icon view ) and drop them at any given point of the same listview...
    VB Code:
    1. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="SendMessageA")]
    2.         [Color=Blue]static[/color] [Color=Blue]extern[/color] [Color=Blue]int[/color] SendMessage (System.IntPtr hwnd, [Color=Blue]int[/color] wMsg, [Color=Blue]int[/color] wParam,[Color=Blue]ref[/color] Point lParam);
    3.         [Color=Blue]const[/color] [Color=Blue]int[/color] LVM_SETITEMPOSITION32  = (0x1000 + 49);
    4.  
    5.         [Color=Blue]private[/color] [Color=Blue]void[/color] ListView1_ItemDrag([Color=Blue]object[/color] sender, System.Windows.Forms.ItemDragEventArgs e)
    6.         {
    7.              ListViewItem lvi =(ListViewItem)e.Item;
    8.              ListView1.DoDragDrop([Color=Blue]new[/color] DataObject("System.Windows.Forms.ListViewItem", lvi), DragDropEffects.Move);
    9.         }
    10.  
    11.         [Color=Blue]private[/color] [Color=Blue]void[/color] ListView1_DragEnter([Color=Blue]object[/color] sender, System.Windows.Forms.DragEventArgs e)
    12.         {
    13.             [Color=Blue]if[/color](e.Data.GetDataPresent("System.Windows.Forms.ListViewItem"))
    14.             {
    15.                  e.Effect = DragDropEffects.Move;
    16.             }
    17.         }
    18.  
    19.         [Color=Blue]private[/color] [Color=Blue]void[/color] ListView1_DragOver([Color=Blue]object[/color] sender, System.Windows.Forms.DragEventArgs e)
    20.         {
    21.              ListViewItem lvi =(ListViewItem)e.Data.GetData("System.Windows.Forms.ListViewItem");
    22.              Point pnt=[Color=Blue]new[/color] Point(e.X - ([Color=Blue]this[/color].Location.X + ListView1.Location.X + 40), e.Y - ([Color=Blue]this[/color].Location.Y + ListView1.Location.Y + 75));
    23.              SendMessage(ListView1.Handle, LVM_SETITEMPOSITION32, lvi.Index,[Color=Blue]ref[/color] pnt);
    24.              e.Effect = DragDropEffects.Move;
    25.         }
    i've included a source project ...
    Attached Files Attached Files
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.