Question Drag drop from vb.net app TO other windows apps

sijcooke

Member
Joined
Nov 29, 2009
Messages
9
Programming Experience
10+
Hi all... please can someone help me!!

There is heaps of vb code out there about dragging from windows in to a vb app.. but pritty much nothing about going the other way!! Please can some one help me - all i want to do is drag a string out of my vb.net app to windows notepad, word, webbrowser url box... or any other text file.

Does it need something like WM_drop or API???

Thanks in advanced!
sijcooke
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,609
Location
Norway
Programming Experience
10+
All you need to do is to call DoDragDrop method and supply your data. Starting the DnD operation is no different whether you intend to drop in your own window or another.

Notepad doesn't support drag-drop text by the way.
 

sijcooke

Member
Joined
Nov 29, 2009
Messages
9
Programming Experience
10+
Hi,
Thanks for the reply. I have used DoDragDrop as shown below and this works fine within my App, but doesn't work anywhere outside of my app - it just has the 'can not drop' mouse cursor!!

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
PictureBox1.DoDragDrop("Text to drag", DragDropEffects.Copy)
End Sub

Many thanks, sijcooke
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,746
Location
Sydney, Australia
Programming Experience
10+
I'm viewing this thread in Firefox. I just wrote this code:
Public Class Form1

    Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
        DoDragDrop("Hello World", DragDropEffects.Copy)
    End Sub

End Class
When I ran the project and dragged from the form into the Quick Reply box, where I'm typing this now, the copy cursor appeared and then, when I dropped, the words Hello World appeared, i.e. it worked exactly as expected.
 
Top Bottom