Results 1 to 5 of 5

Thread: [2008] Drag Drop image object with image as cursor

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    [2008] Drag Drop image object with image as cursor

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008] Drag Drop image object with image as cursor

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: [2008] Drag Drop image object with image as cursor

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008] Drag Drop image object with image as cursor

    Quote Originally Posted by Xancholy
    Thanks. compile the C++ project into a DLL - can I use the VC++ Express edition to do that ?
    You certainly should be able to.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    515

    Re: [2008] Drag Drop image object with image as cursor

    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
    Attached Files Attached Files
    Last edited by Xancholy; Dec 12th, 2008 at 03:59 PM.

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