Results 1 to 12 of 12

Thread: Drag & Drop

  1. #1

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Drag & Drop

    Let's say I have a ListView with items in it, and I set it OLEDragMode to automatic. If I drag any of this items into a simple exe which code's is:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.    MsgBox Command$
    5.    End
    6. End Sub
    I get no message at all. How do I get the dragged item to actually drop a command line on this exe... for starters.

    The idea is to have the full path in the CommandLine and when it's dropped, the file would be copied into that location (Desktop, Folder, whatever)
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  2. #2

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Drag & Drop

    Anyone?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Drag & Drop

    He wants to drop a filename from a list onto an .exe to have it open. (ie mp3 onto player)

  5. #5

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Drag & Drop

    I want to drop the selected files (which are not files obviously) in my app's listview into anything. For example, if I drop them into the desktop, I want Windows to copy these files into that location.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Drag & Drop

    You need to change your listview to Manual dragdrop. When its automatic the listview does not designate text as the source data.

    You can test this out by dragging a text file from explorer to your exe and drop it on to it. The path and filename will popup. With the
    listview being in automatic DND you can not specify the item to pass as the source data.

    Set your listview as manual DND and then write the procedures to initiate the DND and set the data source as the selected listview item's text property.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Drag & Drop

    Quote Originally Posted by RobDog888
    You need to change your listview to Manual dragdrop. When its automatic the listview does not designate text as the source data.

    You can test this out by dragging a text file from explorer to your exe and drop it on to it. The path and filename will popup. With the
    listview being in automatic DND you can not specify the item to pass as the source data.

    Set your listview as manual DND and then write the procedures to initiate the DND and set the data source as the selected listview item's text property.
    I figured that much already... but I don't know how to set the data so that it can be interpreted correctly by Windows. I tried to:

    VB Code:
    1. Data.Files.Add "C:\test.txt"

    but didn't work.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Drag & Drop

    You probably need to use these three procedures...
    VB Code:
    1. Private Sub ListView1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
    2.  
    3. End Sub
    4.  
    5. Private Sub ListView1_OLESetData(Data As MSComctlLib.DataObject, DataFormat As Integer)
    6.  
    7. End Sub
    8.  
    9. Private Sub ListView1_OLECompleteDrag(Effect As Long)
    10.  
    11. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Drag & Drop

    Quote Originally Posted by RobDog888
    You probably need to use these three procedures...
    VB Code:
    1. Private Sub ListView1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
    2.  
    3. End Sub
    4.  
    5. Private Sub ListView1_OLESetData(Data As MSComctlLib.DataObject, DataFormat As Integer)
    6.  
    7. End Sub
    8.  
    9. Private Sub ListView1_OLECompleteDrag(Effect As Long)
    10.  
    11. End Sub
    Ok... but how should I populate the Data object? The line I tried did not work.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Drag & Drop

    This is what I tried but I think there is still more needed?
    VB Code:
    1. 'Using Automatic drop mode and setting the drag data.
    2. Private Sub ListView1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
    3.     Data.Clear
    4.     AllowedEffects = vbDropEffectCopy
    5.     Data.SetData ListView1.SelectedItem.Text, vbCFText
    6. End Sub
    7.  
    8. Private Sub ListView1_OLESetData(Data As MSComctlLib.DataObject, DataFormat As Integer)
    9.     Data.SetData ListView1.SelectedItem.Text, vbCFText
    10. End Sub
    11.  
    12. Private Sub ListView1_OLECompleteDrag(Effect As Long)
    13.     Effect = vbDropEffectCopy '?
    14. End Sub
    Using the Manuladrop mode requires more code, but automatic says it can allow you to set the data manually but it still isnt working.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: Drag & Drop

    Quote Originally Posted by RobDog888
    This is what I tried but I think there is still more needed?
    VB Code:
    1. 'Using Automatic drop mode and setting the drag data.
    2. Private Sub ListView1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
    3.     Data.Clear
    4.     AllowedEffects = vbDropEffectCopy
    5.     Data.SetData ListView1.SelectedItem.Text, vbCFText
    6. End Sub
    7.  
    8. Private Sub ListView1_OLESetData(Data As MSComctlLib.DataObject, DataFormat As Integer)
    9.     Data.SetData ListView1.SelectedItem.Text, vbCFText
    10. End Sub
    11.  
    12. Private Sub ListView1_OLECompleteDrag(Effect As Long)
    13.     Effect = vbDropEffectCopy '?
    14. End Sub
    Using the Manuladrop mode requires more code, but automatic says it can allow you to set the data manually but it still isnt working.
    I cannot drop it anywhere the "forbidden" icon is shown everywhere. How can I change it to automatic drop. ListView's OLEDropMode can be none or manual.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Drag & Drop

    I'm not too sure since I havent used DND this way. My code example was just illustrate some of the stuff needed, but is only half the
    issue. Its not complete or functional.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width