Can anyone please tell me how I can use the image of a file being dragged as custom cursor when I drag drop it onto a form.
I found this perfect code but I don't know C#.
Any help to convert it to VB.NET would be appreciated.
Printable View
Can anyone please tell me how I can use the image of a file being dragged as custom cursor when I drag drop it onto a form.
I found this perfect code but I don't know C#.
Any help to convert it to VB.NET would be appreciated.
Did you actually read that article? The author says that they didn't want to mess about with pinvoke so they wrote all the code in managed C++. There is no simple translation to VB for that, for the very same reason that the author didn't use C# in the first place. You should do exactly what they did: compile the C++ project into a DLL and then reference it form your application project. There's only one tiny bit of C# code at the very end that you'd need to convert to VB and most online code converters will be able to handle that. If not, Instant VB, which has a trial version, will have no trouble at all.
Thanks. compile the C++ project into a DLL - can I use the VC++ Express edition to do that ?
I can figure out the C# code translation part.
You certainly should be able to.Quote:
Originally Posted by Xancholy
Here's some code I've been testing using ShellUtils.dll. If there is a better way, please let me know.
Code:Imports ShellUtils
Public Class frmDragDrop
Private m_dtTest As ShellUtils.DropTarget = Nothing
Private Sub frmDragDrop_DragDrop(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
'Add code to handle "drop" here
End Sub
Private Sub frmDragDrop_DragEnter(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
e.Effect = DragDropEffects.None
If e.Data.GetDataPresent(DataFormats.FileDrop) Then _
e.Effect = DragDropEffects.Copy
m_dtTest.DragEnter(Me.PointToClient(New Point(e.X, e.Y)), e.Effect, e.Data)
End Sub
Private Sub frmDragDrop_DragLeave(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.DragLeave
m_dtTest.DragLeave()
End Sub
Private Sub frmDragDrop_DragOver(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragOver
e.Effect = DragDropEffects.None
If e.Data.GetDataPresent(DataFormats.FileDrop) Then _
e.Effect = DragDropEffects.Copy
m_dtTest.DragOver(Me.PointToClient(New Point(e.X, e.Y)), e.Effect)
End Sub
Private Sub frmDragDrop_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
Me.AllowDrop = True
m_dtTest = New DropTarget(Me.Handle)
End Sub
End Class