[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1283
  • Last Modified:

Hiding the mouse cursor

I did a search on this, but don't think I found what I was looking for.

Using VC++ 6.0, what is the mose appropriate way to hide the mouse cursor? I found one thread that would move the pointer off screen to the lower right, but wouldn't that keep the actual mouse location there? Note, I do not want to disable the mouse, or otherwise affect the  WM_MOUSEMOVE and associated message paramaters that represent the mouse location, the user will still be using the mouse, but I am capturing the movement, and rather than showing a cursor, drawing a graphical cross-hair overlay on the screen (not a cursor per say) that follows it, so I need to simply make the system mouse cursor invisible, but affect it in no other way. The overlay stuff is all working, so I just need to make the system cursor invisible (and of course be able to turn it back on as well :)

Thanks!
-Paul
0
PMH4514
Asked:
PMH4514
  • 3
  • 2
2 Solutions
 
jkrCommented:
What about using

ShowCursor(FALSE); // hide

//...

ShowCursor(TRUE); // show again

?
0
 
PMH4514Author Commented:
oh..

simple enough! I thought I'd have to use DirectX or replace it with a transparent empty bitmap or something.

:)

-Paul

0
 
AlexFMCommented:
Create empty cursor in the project resources. This cursor should contain only transparent background. Load this cursor using LoadCursor function:
HCURSOR hInvisibleCursor = AfxGetApp()->LoadCursor(IDC_CURSOR_INVISIBLE);

Overwrite OnSetCursor function. Of you want to make cursor invisible, call SetCursor(hInvisibleCursor) and return TRUE. If you want to show standard cursor, call base class function:
return CWnd::OnSetCursor(pWnd, nHitTest, message);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
PMH4514Author Commented:
ShowCursor(FALSE) makes it disappear, but ShowCursor(TRUE) doesn't seem to bring it back.

-Paul
0
 
jkrCommented:
You need to 'balance' the calls, i.e. if you called this API twice using FALSE, you need to call it twice using TRUE.
0
 
PMH4514Author Commented:
>> You need to 'balance' the calls
Ahh.. I see.


AlexFM's solution worked perfectly.


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now