Hiding the mouse cursor

Posted on 2004-11-23
Last Modified: 2013-11-20
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 :)

Question by:PMH4514
    LVL 86

    Expert Comment

    What about using

    ShowCursor(FALSE); // hide


    ShowCursor(TRUE); // show again


    Author Comment


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



    LVL 48

    Accepted Solution

    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);

    Author Comment

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

    LVL 86

    Assisted Solution

    You need to 'balance' the calls, i.e. if you called this API twice using FALSE, you need to call it twice using TRUE.

    Author Comment

    >> You need to 'balance' the calls
    Ahh.. I see.

    AlexFM's solution worked perfectly.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now