i couldn't use your .ico file.
i've attached the file i used at the end of this post.
be careful using this code as it's difficult to restore you standard arrow cursor:
vb Code:
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll")> _
Friend Shared Function SetSystemCursor(ByVal hCursor As IntPtr, ByVal id As UInteger) As Boolean
End Function
<DllImport("user32.dll")> _
Friend Shared Function LoadCursor(ByVal hInstance As IntPtr, ByVal id As UInteger) As IntPtr
End Function
Public Const OCR_CROSS As UInteger = 32515
Public Const OCR_WAIT As UInteger = 32514
Public Const IDC_ARROW As UInteger = 32512
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim b As New Bitmap("C:\Users\Paul\Desktop\picker.png")
b.MakeTransparent(Color.White)
Dim c As Cursor = create.CreateCursor(b, 0, b.Height)
SetSystemCursor(c.Handle, IDC_ARROW)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim currentDefaultCursor As New Cursor("C:\Windows\Cursors\arrow_i.cur")
as i said i couldn't find the original cursor that was changed + the black cursor is what i could find
This seems to work for me in XP32, got the idea from vb6 code on vbhelper.com.
Code:
Imports System.Runtime.InteropServices
Public Class Form1
Private old_cursor As IntPtr
Private Declare Function GetCursor Lib "user32.dll" () As IntPtr
<DllImport("user32.dll")> _
Public Shared Function CopyIcon(ByVal hIcon As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")> _
Friend Shared Function SetSystemCursor(ByVal hCursor As IntPtr, ByVal id As UInteger) As Boolean
End Function
Public Const IDC_ARROW As UInteger = 32512
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
old_cursor = GetCursor()
old_cursor = CopyIcon(old_cursor)
'
Dim b As New Bitmap("R:\picker.png") ' our image
b.MakeTransparent(Color.White)
Dim c As Cursor = create.CreateCursor(b, 0, b.Height)
SetSystemCursor(c.Handle, IDC_ARROW)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SetSystemCursor(old_cursor, IDC_ARROW)
End Sub
End Class
Last edited by Edgemeal; Dec 29th, 2011 at 12:50 AM.
Reason: remove uneeded api