Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Hiding Mouse Pointer at Run-time

During run-time, for a particular reason, how do i hide/unhide mouse pointer?

Here's how to hide the Mousepointer: The Declaration:

Declare Function ShowCursor Lib "User" (ByVal bShow As Integer) As Integer
The Call:
x = ShowCursor(True)
x = ShowCursor(False)
Be careful, though! This can backfire on the VB programmer just as it can backfire on any other Windows Programmer. Because the cursor is a shared resource, there is an internal *cumulative* cursor display-count so that different processes can elect to show or hide the cursor. Below is a paraphrasing (mine) of what the Win SDK has to say on the ShowCursor fuction:
"The true or false argument specifies whether the display count is incremented or decremented. If TRUE, the display count is incremented; otherwise, it is decremented. The return value is the new display count, if the function is successful. The cursor is visible only if the count is greater than or equal to zero. If a mouse exists, the initial setting of the cursor show level is zero; otherwise, it is -1. A window that hides the cursor should show it before the cursor leaves its client area or before the window relinquishes control to another window."
In a nutshell, if you elect to hide the cursor, show it again before your process ends! The thing most folks use this for is making screensavers (which is really just a renamed executable with a couple teeny bells and whistles for command-line parsing and that sets a true/false state to Windows to "tell it" a screensaver is running), or games/graphics where the mousepointer gets in the way.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date