PDA

Click to See Complete Forum and Search --> : Cursor Image


Dafly
Dec 30th, 1999, 03:50 AM
Hi what I am trying to do is when the user holds down the 'Shift' key and the left mouse button the Cursor changes from the Arrow to a diffrent Image Not just on the form but on all of the other programs, I have it to were it changes the Cursor Image but it returns the cursor Image back to the arrow after the mouse is moved. the code i have is.

Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long

Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long

Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer


Dim z as long

Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyShift) Then
If GetAsyncKeyState(vbLeftButton) Then

SetCursor z

End If
End If
End Sub

Private Sub Form_Load()
z = LoadCursorFromFile("Icon.cur")
End Sub


Is their away to set the system mouse pointer to one that I specifiy, or is their an better way to do this?

Thank you,
Jeremy


------------------
Dafly98@aol.com

Serge
Dec 30th, 1999, 10:43 AM
Try something like this:

Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private m_lIcon As Long

Private Sub Form_Load()
m_lIcon = LoadCursorFromFile("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Win95\Drive.ico")
Timer1.Interval = 100
End Sub


Private Sub Timer1_Timer()
Do While GetAsyncKeyState(vbKeyShift)
If GetAsyncKeyState(vbLeftButton) Then
SetCursor m_lIcon
End If
Loop
End Sub


------------------

Serge

Software Developer
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)