Important alert: (current site time 7/16/2013 1:37:44 AM EDT)
 

VB icon

!!!*Hide the Mouse Pointer!! EASY!*!!!

Email
Submitted on: 8/10/1999
By: SeeD  
Level: Not Given
User Rating: By 24 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 59248
(About the author)
 
     This simple code hides the mouse pointer when you want to. (o:
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: !!!*Hide the Mouse Pointer!!EASY!*!!!
' Description:This simple code hides the mouse pointer when you want to. (o:
' By: SeeD
'
' Inputs:Make a new project. Add a module. Add 2 Command Buttons.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2902&lngWId=1'for details.'**************************************

'put this in your module
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
'ok, that's it. (o:


Other 32 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

8/10/1999 3:06:00 PMThis is SeeD (o:

just make sure you dont get the cursor lost! I'd suggest putting the command buttons really close to eachother!
(If this comment was disrespectful, please report it.)

 
8/23/1999 11:28:00 PMDekel

i am a beginer plz explain what this doing
Declare Function ShowCursor& Lib "user32" _
(ByVal bShow As Long)
'Add this code to Command1.
(If this comment was disrespectful, please report it.)

 
9/4/1999 2:11:00 PMAdam Spicer

NICE!!! been looking for something this easy
(If this comment was disrespectful, please report it.)

 
9/30/1999 2:03:00 PMthe Spruce Moose

Hey man! Nice code! Very easy to use, appreciate it!
(If this comment was disrespectful, please report it.)

 
11/12/1999 12:48:00 PMCosmo

THANKS !!!!!!!!!!!!!! I've needed this.
(If this comment was disrespectful, please report it.)

 
1/13/2000 1:21:22 PMGrim Reaper

Yeah Sure it only makes it disappear on the form, anywhere else it comes back
(If this comment was disrespectful, please report it.)

 
1/14/2000 9:30:44 PMHelp

HELP please, the mouse hides but it
does not come back...
What is wrong, can anyone help
please
(If this comment was disrespectful, please report it.)

 
1/15/2000 5:40:09 PMtheLoft

I am having the same problem
It hides the mouse but it stops
reading the mouse movement. So my
form mouse Movement code does not execute
Can anyone Plz Help!
How do I get it to recognize the mouse movement
again?
(If this comment was disrespectful, please report it.)

 
3/11/2000 7:01:56 AMJohannes Eder

err this only works on my form. I know there's a way to hide the curser everywhere, but I can't remember *sigh*
(If this comment was disrespectful, please report it.)

 
4/23/2000 11:19:25 PMetrask

For those of you who have problems with
losing the mouse, I suggest making a shortcut
button for the showmouse procedure. To
do this, type a name like Sho&w in the caption
then you can press ctrl+w and it should show the mouse

your welcome
(If this comment was disrespectful, please report it.)

 
6/20/2000 12:01:05 PMoskilian

just a suggestion:
if instead of writing ShowCursor (bShow = True), you can write ShowCursor 0 (to hide it) or ShowCursor 1 (to show it). it´s shorter, but the same.
(If this comment was disrespectful, please report it.)

 
11/10/2000 9:33:34 AMmalawi

Declare Function ShowCursor& Lib
"user32" _(ByVal bShow As Long)
goes in a module

Uou can use ShowCursor (True) instead of ShowCursor (bShow = True)

(If this comment was disrespectful, please report it.)

 
7/8/2001 5:19:29 PMTaylor Marlowe

Nice code cept my mouse cousur is lost in vb right now and your code to get it back doesnt work
(If this comment was disrespectful, please report it.)

 
8/12/2001 8:45:58 AMbob!

module = ?... the code isn't working over here, i have the commands setup, does it go in general declarations? form load? please help!
(If this comment was disrespectful, please report it.)

 
10/23/2001 4:57:30 AMAlpha

Nah... Just this

Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
ShowCursor False 'Hide
ShowCursor True 'Show

And in case you have lost your cursor and wanna click on another button to get it back simply press "Tab" key once to switch the focus or set the hotkey (like Caption="&Show Cursor").
(If this comment was disrespectful, please report it.)

 
10/23/2001 5:00:27 AMAlpha

Again...

Place this in the top most of the code:
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

Code to hide the cursor
ShowCursor False

To show it:
ShowCursor True
(If this comment was disrespectful, please report it.)

 
10/31/2001 4:55:41 PMSFR

Works Great for My POS Application
(If this comment was disrespectful, please report it.)

 
4/2/2002 2:11:43 AMhilljd00

That script it great, it works prefect for me, all some of you have to do is, make a 'module' and put this:
Declare Function ShowCursor
(If this comment was disrespectful, please report it.)

 
4/2/2002 2:12:20 AMhilljd00

That script it great, it works prefect for me, all some of you have to do is, make a 'module' and put this:
Declare Function ShowCursor& Lib "user32" _
(ByVal bShow As Long)

So take it out of the form1 and put it module! :>
(If this comment was disrespectful, please report it.)

 
4/15/2002 5:11:33 PMJUSTIN

bShow is a non-defined variable!
(If this comment was disrespectful, please report it.)

 
4/23/2002 3:01:50 PMLiquid Khaos

Instead just make the mouse pointer an all transparent pointer for your app. Use a right click to make it come back. No voodoo no lost mouse. Remember 'well done' is far superior to 'Well said'
(If this comment was disrespectful, please report it.)

 
5/9/2002 2:35:48 PMdotar

It doesn't work for me!
I can't hide the mouse..
(If this comment was disrespectful, please report it.)

 
6/6/2002 7:54:02 PMBrain

Does any one know how you can hide your mouse with multiple forms? It works on single form projects, but when i try it for multiple form projects it comes with a definition error. Can anyone help???
(If this comment was disrespectful, please report it.)

 
9/19/2002 11:14:34 PM

This Code Reali Work IS Good Thanx
(If this comment was disrespectful, please report it.)

 
7/27/2003 6:53:20 PM

Thank's, I really needed!!!
(If this comment was disrespectful, please report it.)

 
5/17/2004 7:09:22 PM

IT DOESNT WORK...SOMTHIN IS WRONG WIT IT
(If this comment was disrespectful, please report it.)

 
5/31/2004 8:31:42 PMLCSBSSRHXXX

you could have done this :

Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

command1_click()
ShowCursor 0
end sub
command2_click
ShowCursor 1
end sub

if your having porblems trying to find ur mouse try pressing :
ctrl + alt + pause break

(If this comment was disrespectful, please report it.)

 
5/31/2004 8:33:35 PMLCSBSSRHXXX

my way it makes the cursor hide any where
(If this comment was disrespectful, please report it.)

 
10/2/2004 1:28:14 PMEd the Hitch Hiker

My guess is those who find the code working is not using WinXP and those who cant get the code to work is using WinXP. I am using WinXP :(
(If this comment was disrespectful, please report it.)

 
12/13/2004 9:18:44 PM

It works with XP, only that if you clik 3 times to the "hide" button you have to click 3 times to "show" so the cursor appears again. Doesn't work in Form_Load. I preffer using the transparent cursor, is more stable and unbuggy. Maybe there's a more complex code to do this work better but no idea...
(If this comment was disrespectful, please report it.)

 
8/6/2005 7:40:22 PMEric S.

It does too work in form load and form unload I’ve used it in my projects before got the code off of allapi.net and it has always worked. My project also uses multi forms and it works perfect on all of them. I’m using windows xp.
(If this comment was disrespectful, please report it.)

 
8/6/2005 7:52:44 PMEric S.

i dont think that you can copyright an api unless you created the dll that uses the api and in this case i know you didn't creat it so it cant be copyrighted
(If this comment was disrespectful, please report it.)

 
8/6/2005 8:03:09 PMEric S.

i use the same dll for keycode with the api GetAsyncKeyState so you didn't make this dll
(If this comment was disrespectful, please report it.)

 
11/29/2005 1:44:20 AMmattz0r

it didnt work for me =\ but im a noobie anyways
(If this comment was disrespectful, please report it.)

 
12/1/2005 12:22:36 AMWill Christ

Most Excelent. Did exactly as you promised! And so simple too. I couldn't have asked for a better solution. Kudos to you!
(If this comment was disrespectful, please report it.)

 
7/18/2006 1:26:35 PMNice

Cool code ...thx 5 globes
(If this comment was disrespectful, please report it.)

 
1/29/2007 5:49:34 PMPeter

Good
(If this comment was disrespectful, please report it.)

 
9/5/2008 7:29:29 AMwaleed

I recommend to put command1 as default botton, then once the command1 has been clicked, change the default botton as command2 (that if you are training on your own computer)
(If this comment was disrespectful, please report it.)

 
4/6/2009 3:55:36 AMakash

hai man,,,
stunning code..
(If this comment was disrespectful, please report it.)

 
5/17/2009 4:07:13 PMgipsy

I thinkmy code is the better one.
You can press Cmd1 as oft as you want.
Pressing cmd2 mousepointer returns at once:
in a form:
Option Explicit

Private Sub Command1_Click()
Do While ShowCursor(False) > -1: DoEvents: Loop
End Sub
'Add this to Command2.


Private Sub Command2_Click()
Do While ShowCursor(True) <= 0: Loop
End Sub

in a module:
Option Explicit

Declare Function ShowCursor& Lib "user32" (ByVal bShow As Long)

(If this comment was disrespectful, please report it.)

 
7/14/2009 10:39:19 AMbijalbhatt

best
(If this comment was disrespectful, please report it.)

 
7/14/2009 10:40:24 AMbijalbhatt

best results
(If this comment was disrespectful, please report it.)

 
11/4/2009 8:33:52 AMRicky

I would make it so that you could hot key the mouse pointer to reappear just in case you did lose it. it would save some people a lot of hassle trying to remember where it is lol
(If this comment was disrespectful, please report it.)

 
3/25/2010 6:25:34 AMNaim

hi, very good code and easy to use.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.