Click to See Complete Forum and Search --> : mousecursor - invisible
jaks
Oct 13th, 2000, 02:25 PM
I need af mousepointer which is invisible (lookthruable)- can anyone point me in the right direction?
I would like to hide the mousecursor when it is over a form.
best regards
Jakob
Use the ShowCursor API.
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Sub cmdHideCursor_Click()
ShowCursor False 'Hide the cursor
End Sub
Private Sub cmdShowCursor_Click()
ShowCursor True 'Show the cursor
End Sub
kedaman
Oct 13th, 2000, 02:37 PM
Just tested it and it works. Place a timer with interval 100 on the form. Paste this code and run.
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Static over As Boolean
Dim mouse As POINTAPI
GetCursorPos mouse
If WindowFromPoint(mouse.x, mouse.y) = hWnd Then
If Not over Then
over = True
ShowCursor 0
End If
Else
If over Then
over = False
ShowCursor 1
End If
End If
End Sub
Mad Compie
Oct 17th, 2000, 02:37 PM
Hey guys, remember thta our friend Windows keeps track of the number of 'shows'.
So, if you do twice a ShowCursor 1&, you also should execute twice ShowCursor 0&.
Sometimes this is very annoying if we are debugging code, because the mouse cursor could be invisible!
kedaman
Oct 18th, 2000, 02:56 AM
Thats correct Compie, well my code should cope with that: The over boolean let's you know what state the cursor is in, and it only reacts if the state is changed.
Mad Compie
Oct 18th, 2000, 01:04 PM
Absolutely, Keda! I was just mentioning it to Jaks.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.