Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

How to tell what the current mouse cursor is.

Is there a way to tell what the current mouse cursor is?
I have the cursor changeing over a image box, and I want to be able to use a timer to check what the cursor is at all times and if it's a certain cursor, do certain things. How can I achieve this???

Thanx in advance,

--Naylin

eg:

If ***how do I tell what the mouse cursor is*** Then
   Do this!
End If
0
Naylin
Asked:
Naylin
  • 2
  • 2
  • 2
  • +1
1 Solution
 
TimCotteeCommented:
Well that could be difficult, you can obtain a handle to the current cursor and draw this onto a picturebox for example, you would then have to determine whether the image you get matches one of your expected cursor images. This is the hard part and probably needs more than 25 pts to get a good answer.

Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Sub Form_Paint()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'Draw the current cursor on this form
    DrawIcon Me.hdc, 0, 0, GetCursor
End Sub
0
 
Richie_SimonettiIT OperationsCommented:
What do you mean by mouse cursor? its image?
if not, maybe you don't need a timer but a MouseMove event from image box

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print Image1.MousePointer
End Sub
0
 
NaylinAuthor Commented:
I hadn't thought of using a MouseMove event! THANKYOU! After changing my code to use it, it works great! It's a bit slower than using the timer, but it works!

Thanks again,

--Naylin
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
NaylinAuthor Commented:
Thanx again!
0
 
Richie_SimonettiIT OperationsCommented:
You are welcome... Glad to help.
0
 
DanieleC88Commented:
Why don't you just use the API Call "GetCursorPos" ?
It gives you absolute X and Y coords of the pointer with a POINTAPI type. It isn't difficult. As you can use GetCursorPos, with the same sintax you can set the mouse pointer's position with SetCursorPos.
0
 
DanieleC88Commented:
Excuse me... I just didn't read all the message... the you just have to use the MousePointer property...
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now