Shoutbox

Hidie mouse in visual basic - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Hidie mouse in visual basic (/showthread.php?tid=25536)

Hidie mouse in visual basic by Necroman on 05-20-2004 at 02:59 PM

I was making a little app in vb that makes a little guy fly accross the screen

and I was wondering how I can hide the mousecursor
I searched the web and I only found info on the ShowCursor function ... but that will only hide the mouse in a certain form

does anybody know how to hide the mouse completely?


RE: Hidie mouse in visual basic by Stigmata on 05-20-2004 at 03:55 PM

hmmmmm get a book mate....


code:
Declare Function ShowCursor& Lib "user32" _
    (ByVal bShow As Long)
    'Add this code to Command1.

Private Sub Command1_Click()

    ShowCursor (bShow = True)
End Sub

'Add this to Command2.

Private Sub Command2_Click()

    ShowCursor (bShow = False)
End Sub


RE: Hidie mouse in visual basic by Necroman on 05-20-2004 at 04:18 PM

with that, you're still able to see the cursor if it is positioned over the taskbar, and when you click to bring another application to the front ... the mouse becomes visible again :S


RE: Hidie mouse in visual basic by dotNorma on 05-20-2004 at 04:20 PM

code:
Private Declare Function ShowCursor Lib "user32" (ByVal lShow As Long) As Long

Public Sub ButtonName_Click()
    ShowCursor False
End Sub

Public Sub ButtonName_Click()
    ShowCursor True
End Sub


When testing use the Tab button to find the other button because it would be hard to click it without being able to see the mouse.
RE: Hidie mouse in visual basic by Stigmata on 05-20-2004 at 04:20 PM

:S


make the form your using a maximsed ontop form :P

eg if linking the form use

code:
private sub command1_click ()
form2.show 1
' the 1 makes it show as a modual which has it on top :P
end sub


RE: Hidie mouse in visual basic by Mike on 05-20-2004 at 04:30 PM

That will only work for your application.
If you want it on top for all windows then you have to use the ShowWindow api if i remember correcly.
I'll post an example when i get home...


RE: Hidie mouse in visual basic by CookieRevised on 05-20-2004 at 04:43 PM

quote:
Originally posted by Mike2
That will only work for your application.
If you want it on top for all windows then you have to use the ShowWindow api if i remember correcly.
I'll post an example when i get home...
eh yeah... but he asked for hiding the mousecursor system-wide, not about a code to show your window alwyas on top (although, that could help him for this application also ;))


To keep your window always on top:
code:
Declare Function SetWindowPos Lib "User" (ByVal h%, ByVal hb%, ByVal X%, ByVal Y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer
Const FLAGS = 1
Const HWND_TOPMOST = -1
' Use the above Declaration and Constants along with
' the code in "Form_Load" to make a window remain On Top.

Sub Form_Load ()
    'Sets form1 always on top.
    Dim Success As Integer
    Success% = SetWindowPos(Form1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
    ' Change the "0's" above to position the window.
End Sub


RE: Hidie mouse in visual basic by Necroman on 05-20-2004 at 04:45 PM

aah, thats how I should have asked the question ...


"how do you hide the mouse system-wide?" :)


RE: Hidie mouse in visual basic by CookieRevised on 05-20-2004 at 05:31 PM

Yeah, and the solution to that is already given...

code:
Private Declare Function ShowCursor Lib "user32" (ByVal lShow As Long) As Long
Sub Form_Load ()
    ShowCursor False
    ' do whatever you want with the mouse gone
    ShowCursor True
End Sub
But keep in mind that if you call the ShowCursor function more than once passing False as an argument, then you must call ShowCursor with True an equal number of times, otherwise the cursor will remain invisible!!!!