Hidie mouse in visual basic |
Author: |
Message: |
Necroman
Junior Member
YUP, that's REAL blood :p
Posts: 62
39 / / –
Joined: Dec 2002
|
O.P. Hidie mouse in visual basic
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?
You ain't drunk till you have to grab the grass to keep from falling off the earth.
---------------------------
I'm not fat, I'm festively plump!
|
|
05-20-2004 02:59 PM |
|
|
Stigmata
Veteran Member
Posts: 3520 Reputation: 45
21 / /
Joined: Jul 2003
|
RE: Hidie mouse in visual basic
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
|
|
05-20-2004 03:55 PM |
|
|
Necroman
Junior Member
YUP, that's REAL blood :p
Posts: 62
39 / / –
Joined: Dec 2002
|
O.P. RE: Hidie mouse in visual basic
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
You ain't drunk till you have to grab the grass to keep from falling off the earth.
---------------------------
I'm not fat, I'm festively plump!
|
|
05-20-2004 04:18 PM |
|
|
dotNorma
Veteran Member
Posts: 1745 Reputation: 17
33 / / –
Joined: May 2003
|
RE: Hidie mouse in visual basic
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.
|
|
05-20-2004 04:20 PM |
|
|
Stigmata
Veteran Member
Posts: 3520 Reputation: 45
21 / /
Joined: Jul 2003
|
RE: Hidie mouse in visual basic
make the form your using a maximsed ontop form
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
end sub
|
|
05-20-2004 04:20 PM |
|
|
Mike
Elite Member
Meet the Spam Family!
Posts: 2795 Reputation: 48
32 / /
Joined: Mar 2003
|
RE: Hidie mouse in visual basic
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...
|
|
05-20-2004 04:30 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Hidie mouse in visual basic
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
This post was edited on 05-20-2004 at 04:59 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
05-20-2004 04:43 PM |
|
|
Necroman
Junior Member
YUP, that's REAL blood :p
Posts: 62
39 / / –
Joined: Dec 2002
|
O.P. RE: Hidie mouse in visual basic
aah, thats how I should have asked the question ...
"how do you hide the mouse system-wide?"
You ain't drunk till you have to grab the grass to keep from falling off the earth.
---------------------------
I'm not fat, I'm festively plump!
|
|
05-20-2004 04:45 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Hidie mouse in visual basic
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!!!!
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
05-20-2004 05:31 PM |
|
|
|