-
Changing Windows Cursor
Does anyone have an example of using LoadCursor and SetCursor to change the Windows cursor ? I've tried it but the LoadCursor call just returns a handle of 0 which causes the SetCursor to make the cursor disappear. I'm using NT if that makes a difference, and here's the code I use :
Code:
' Used to set the cursor to the crosshair on all app's
Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorW" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
' Crosshair cursor
Private Const IDC_CROSS = 32515&
Private Sub Command1_Click()
Dim hCursor As Long
Dim RetVal As Long
' Change the cursor to a crosshair - returns 0 at the moment !
hCursor = LoadCursor(ByVal 0&, IDC_CROSS)
RetVal = SetCursor(hCursor)
End Sub
Thanks in advance.
-
You don't really need API For this.
Code:
Screen.MousePointer = 99
Screen.MousePointer = LoadPicture(MyCursor.cur)
To hide the Mouse, use the ShowCursor function.
-
Actually the MouseIcon property should be used in the 2nd line.
Or if you just want the crosshair:
Code:
Screen.MousePointer = vbCrosshair
:rolleyes: < (ignore, I must)
-
Yes, it should.
(Sorry, I just copied and pasted the line)
-
Cheers guys, I was being particularly dim when I asked. I had API on the brain and didn't think VB might actually do it for me !
-
Don't worry - VB usually can't do much by itself anyway :rolleyes: