No mouse cursor

TechnoTone

Junior Contributor
Joined
Jan 20, 2003
Messages
224
Location
UK - London
How do you set the mouse cursor to nothing. I want the ability to hide and show the cursor on my form.

I can think of a work around whereby I move the cursor to the bottom left corner of the screen but this isn't ideal.
 
I'm still having trouble with this. I have a form with a timer that detects when the mouse moves and then displays a couple of buttons and the mouse cursor. After 3 seconds it is then supposed to hide the buttons and the mouse cursor. Unfortunately, it does't hide the mouse cursor.

The form code is attached.

:confused: :confused: :confused:
 

Attachments

try something like this :
Visual Basic:
Dim x As Integer = 0
'/// somewhere near top of your form ( under windows generated code )
'//////////
    Private Sub Form1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.MouseEnter
        Timer1.Start()
        Button2.Visible = True
        Button3.Visible = True
    End Sub

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        x += 1
        If x = 3 Then
            Timer1.Stop()
            Button2.Visible = False
            Button3.Visible = False
            x = 0 '/// reset the counter
        End If
    End Sub
 
One thing about Cursor.Show()/Hide() is that it doesn't seem to work if not invoked on the main thread. In my first reply to your post, I tested it first on a separate thread but it didn't work. Maybe that behavior is related to what you're experiencing now since you're trying to invoke Cursor.Show()/Hide() from the Tick event of a timer.
 
Another way...

With this I get error messages about intances and such:
JABE said:
You can use Cursor.Hide() and Cursor.Show()

But this API worked nicely:
Visual Basic:
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Boolean) As Long

And simply call it like this:
Visual Basic:
ShowCursor(False)
ShowCursor(True)
 
Back
Top