You can use a color cursor from a bitmap with GetHicon
Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'Getting the Hicon from a 24x24 image I added as a resource.
Me.Cursor = New Cursor(My.Resources.Forum24.GetHicon)
End Sub
That will give you a color cursor but you will notice it sets the hot spot at the center of the image.
You will need to make some api calls to change the hot spot.
Here is what you need to add to your class.
Private Structure IconInfo
Public fIcon As Boolean
Public xHotspot As Integer
Public yHotspot As Integer
Public hbmMask As IntPtr
Public hbmColor As IntPtr
End Structure
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function GetIconInfo(ByVal hIcon As IntPtr, ByRef pIconInfo As IconInfo) As Boolean
End Function
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function CreateIconIndirect(ByRef icon As IconInfo) As IntPtr
End Function
Now to set the hot spot.
Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'Get the Hicon from the bitmap
Dim BitmapPtr As IntPtr = My.Resources.Forum24.GetHicon
Dim IconInfo As IconInfo = New IconInfo()
Dim CursorPtr As IntPtr
'This will set the hbmMask and Color fields of the
'IconInfo structure
GetIconInfo(BitmapPtr, IconInfo)
'Now you can set the x and y hotspot
IconInfo.xHotspot = 0
IconInfo.yHotspot = 0
IconInfo.fIcon = False 'True for Icon; False for cursor
'Get a handle for the cursor
CursorPtr = CreateIconIndirect(IconInfo)
'Now create the cursor from the handle
Me.Cursor = New Cursor(CursorPtr)
End Sub
The hot spot will now be at 0,0.
Do a search on the msdn library for IconInfo, GetIconInfo, and CreateIconIndirect.