CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    May 2005
    Location
    Germany
    Posts
    21

    Unhappy visibility of mouse cursor

    I've read that ShowCursor(false) makes the mouse cursor invisible. But unfortunately only in my own application! I would like to switch it of everywhere. No visible mouse cursor!

    I'm already searching for quite a long time. With no success.

    Please help.

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: visibility of mouse cursor

    it only work on yor app and its ok.
    if you want to change it per all app you should consider using the ::SetSystemCursor(..) api that what i would do.

    Cheers
    Shahar

  3. #3
    Join Date
    May 2005
    Location
    Germany
    Posts
    21

    Re: visibility of mouse cursor

    Thank you Shahar,

    I didn't want to change the systems cursor.
    And in the case of SetSystemCursor(..) I would have to set
    every single system cursor (hourglass, arrow, ..) to something
    invisible.

    Isn't there a way to make it just invisble instead of replacing it?

  4. #4
    Join Date
    May 2005
    Posts
    4,954

    Re: visibility of mouse cursor

    well you can do another thing, you can set a mouse hook function:

    ::SetWindowsHookEx ( ) with the WH_MOUSE_LL parameter and on each callback from the hook set the x,y paramters to unvisiable coordinates and then your mouse will never appear on screen, no matter what app is running.

    Cheers
    Shahar

  5. #5
    Join Date
    May 2005
    Location
    Germany
    Posts
    21

    Re: visibility of mouse cursor

    Yes, I also thought of this solution.
    But I want to leave the cursor where it is.
    The mouse should still work, invisible.
    To me it seems incredible how it can be
    so difficult to simply make the cursor invisible.

  6. #6
    Join Date
    May 2005
    Posts
    4,954

    Re: visibility of mouse cursor

    i have simple solution for you:
    RECT rc;
    this->GetWindowRect(&rc);
    ::ClipCursor(&rcClip);
    ::ShowCursor(0);

    after that you wont see the cursor i am promising you :-)

    Cheers
    Shahar

  7. #7
    Join Date
    May 2005
    Location
    Germany
    Posts
    21

    Wink Re: visibility of mouse cursor

    Cool idea...
    But unfortunately the mouse will be restricted to
    a very small part of the desktop (&rcClip) and
    can not be moved freely.

  8. #8
    Join Date
    May 2005
    Posts
    4,954

    Re: visibility of mouse cursor

    but you wanted it to be HIdden? so what do you care? now i dont really understand what you want :-(

    Cheers
    Shahar

  9. #9
    Join Date
    May 2005
    Location
    Germany
    Posts
    21

    Re: visibility of mouse cursor

    I would like to use the mouse as usual but without seeing the cursor. The obviously needed visual feedback(current position of the cursor) will come from other sources. No matter what kind of sources.

  10. #10
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: visibility of mouse cursor

    I suggest that you use your own cursor system, only in your application window (using SetCursor(NULL)).

    Even, if you can modify the cursor for all applications, that is very bad, because applications like text editor or image editor, generally need their own cursors.
    For example it is good that an image editor has a cursor indicating the type of operation (brush, pen, zoom, fill, duplicate, selection, etc.)
    If you remove this cursor and replace it by your own cursor system, it will be very bad for the user, because only one cursor will be used for all tools of all applications.

    If your application is a game, you can allow the user to run it in fullscreen mode for a better immersion in the game, but in windowed mode the cursor must be normal when the mouse get out of the window.

  11. #11
    Join Date
    May 2001
    Location
    Oslo, Norway
    Posts
    610

    Re: visibility of mouse cursor

    I agree. Dont mess with system cursor, there is a reason there is no API to hide it. Are you trying to replace whole Windows with your own system ?!

    Can you tell us WHY do you want to hide it ?

  12. #12
    Join Date
    Jan 2005
    Posts
    4

    Thumbs up Re: visibility of mouse cursor

    hey guys,

    You can hide the mouse cursor completely so that it will not be visible when ur mouse crosses ur application window boundaries as follows:

    Use SetCapture() to capture the mouse..and then use ShowCursor(false)

    Pls make sure that you read ShowCursor in MSDN first...

    By doing this only and only ur app receives the mouse events...don't worry...
    you can even route the messages to other apps by using ::GetWindowFromPoint and ::PostMessage.....u need to convert the mouse coordinates into screen coordinates for this....use ClientToScreen()..

    Using System wide Mouse Hooks is another solution

    Anand.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured