
Originally Posted by
i00
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:
#Region " CreateIconIndirect"
Private Structure IconInfo
Public fIcon As Boolean
Public xHotspot As Int32
Public yHotspot As Int32
Public hbmMask As IntPtr
Public hbmColor As IntPtr
End Structure
<DllImport("user32.dll", EntryPoint:="CreateIconIndirect")> _
Private Shared Function CreateIconIndirect(ByVal iconInfo As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function DestroyIcon(ByVal handle As IntPtr) As Boolean
End Function
<DllImport("gdi32.dll")> _
Public Shared Function DeleteObject(ByVal hObject As IntPtr) As Boolean
End Function
''' <summary>
''' CreateCursor
''' </summary>
''' <param name="bmp"></param>
''' <returns>custom Cursor</returns>
''' <remarks>creates a custom cursor from a bitmap</remarks>
Public Shared Function CreateCursor(ByVal bmp As Bitmap) As Cursor
'Setup the Cursors IconInfo
Dim tmp As New IconInfo
tmp.xHotspot = 0
tmp.yHotspot = 0
tmp.fIcon = False
tmp.hbmMask = bmp.GetHbitmap()
tmp.hbmColor = bmp.GetHbitmap()
'Create the Pointer for the Cursor Icon
Dim pnt As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(tmp))
Marshal.StructureToPtr(tmp, pnt, True)
Dim curPtr As IntPtr = CreateIconIndirect(pnt)
'Clean Up
DestroyIcon(pnt)
DeleteObject(tmp.hbmMask)
DeleteObject(tmp.hbmColor)
Return New Cursor(curPtr)
End Function
#End Region