Results 1 to 7 of 7

Thread: [RESOLVED] Drag drop "overlay picture"

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Resolved [RESOLVED] Drag drop "overlay picture"

    In windows when you drag from explorer there is a custom "picture" when the items are dragged ... how can i do this in vb.net?

    I know how to do drag drop but not with the picture...

    also note: I DO NOT just want to change the cursor icon ... in explorer the drag picture can be bigger than 32x32 and i need it to be in my project also

    Thanks in advance
    Kris

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221
    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
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Drag drop "overlay picture"

    what are you D+D'ing?

    cursors aren't limited to 32*32. they can be any shape or size.

  4. #4

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: Drag drop "overlay picture"

    does anyone know of an example that is in VB not C# and C++?

    Thanks
    Kris

  5. #5

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: Drag drop "overlay picture"

    and just checked u can change the cursor bigger than 32x32 - so i guess changing the cursor would be fine 2...

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Drag drop "overlay picture"

    Quote Originally Posted by i00 View Post
    and just checked u can change the cursor bigger than 32x32 - so i guess changing the cursor would be fine 2...
    as I told you in post #3.

    anyway, you create a bitmap for your cursor + then create a cursor from your bitmap:

    vb Code:
    1. #Region "   CreateIconIndirect"
    2.  
    3.     Private Structure IconInfo
    4.         Public fIcon As Boolean
    5.         Public xHotspot As Int32
    6.         Public yHotspot As Int32
    7.         Public hbmMask As IntPtr
    8.         Public hbmColor As IntPtr
    9.     End Structure
    10.  
    11.     <DllImport("user32.dll", EntryPoint:="CreateIconIndirect")> _
    12.     Private Shared Function CreateIconIndirect(ByVal iconInfo As IntPtr) As IntPtr
    13.     End Function
    14.  
    15.     <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
    16.     Public Shared Function DestroyIcon(ByVal handle As IntPtr) As Boolean
    17.     End Function
    18.  
    19.     <DllImport("gdi32.dll")> _
    20.     Public Shared Function DeleteObject(ByVal hObject As IntPtr) As Boolean
    21.     End Function
    22.  
    23.     ''' <summary>
    24.     ''' CreateCursor
    25.     ''' </summary>
    26.     ''' <param name="bmp"></param>
    27.     ''' <returns>custom Cursor</returns>
    28.     ''' <remarks>creates a custom cursor from a bitmap</remarks>
    29.     Public Shared Function CreateCursor(ByVal bmp As Bitmap) As Cursor
    30.         'Setup the Cursors IconInfo
    31.         Dim tmp As New IconInfo
    32.         tmp.xHotspot = 0
    33.         tmp.yHotspot = 0
    34.         tmp.fIcon = False
    35.         tmp.hbmMask = bmp.GetHbitmap()
    36.         tmp.hbmColor = bmp.GetHbitmap()
    37.  
    38.         'Create the Pointer for the Cursor Icon
    39.         Dim pnt As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(tmp))
    40.         Marshal.StructureToPtr(tmp, pnt, True)
    41.         Dim curPtr As IntPtr = CreateIconIndirect(pnt)
    42.  
    43.         'Clean Up
    44.         DestroyIcon(pnt)
    45.         DeleteObject(tmp.hbmMask)
    46.         DeleteObject(tmp.hbmColor)
    47.  
    48.         Return New Cursor(curPtr)
    49.     End Function
    50.  
    51. #End Region

  7. #7

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: Drag drop "overlay picture"

    sorry i actually resolved this before your post

    Thanks anyway
    Kris

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