Skip to content
TheChatArchiveThe Chat Archive
o3-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

Does Windows 11 (or Windows 10) offer an API for hiding/showing the mouse pointer?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-30b-a3b’s answer.
  1. User

    Does Windows 11 (or Windows 10) offer an API for hiding/showing the mouse pointer?

  2. Assistant

    Yes — the same classic Win32 API that has been around since Windows 3.x is still the correct (and officially supported) way to hide or show the mouse pointer on Windows 10 and Windows 11.
    Below are the most common approaches, plus how you’d do it from .NET, UWP/WinUI, and WPF.


    1. Win32 (C / C++)

    The user32 .dll function you want is ShowCursor (BOOL bShow).

    • It maintains an internal display-count:
    – If the count is ≥ 0, the cursor is visible.
    – If the count is < 0, the cursor is hidden.
    • Every call with bShow = TRUE increments the count; every call with bShow = FALSE decrements it.
    • Because other code (or Windows itself) might have already changed the count, the usual pattern is to loop until you reach the desired state.

    #include <windows.h>
    
    void HideCursor()
    {
        // Decrement until it’s actually hidden
        while (ShowCursor(FALSE) >= 0) { /* keep going */ }
    }
    
    void ShowCursorAgain()
    {
        // Increment until it’s actually shown
        while (ShowCursor(TRUE)  < 0) { /* keep going */ }
    }
    

    Important notes
    • The cursor only disappears while your thread’s window has mouse input (is in the foreground or has capture).
    • If you switch to another process/window, Windows will automatically restore the visible cursor for that window.
    • There is no special “Windows 11 API”: the same user32.ShowCursor works on every desktop Windows version.


    1. Setting a NULL cursor for your window

    Another idiom is to just give your window a “null” cursor:

    // WM_SETCURSOR handler
    case WM_SETCURSOR:
        SetCursor(NULL);   // or LoadCursor(hInst, MAKEINTRESOURCE(…))
        return TRUE;       // we handled it
    

    That approach doesn’t affect the global display count, so you don’t have to juggle ShowCursor’s internal counter.
    Again, the cursor is hidden only while the mouse is inside your window.


    1. .NET / WPF

    // WPF: hide
    Mouse.OverrideCursor = Cursors.None;
    
    // ... later: restore system default
    Mouse.OverrideCursor = null;
    

    OverrideCursor is per-thread (i.e., per window/UI context).


    1. .NET / WinForms

    using System.Runtime.InteropServices;
    
    [DllImport("user32.dll")]
    static extern int ShowCursor(bool bShow);
    
    // Hide
    while (ShowCursor(false) >= 0) {}
    
    // Show
    while (ShowCursor(true) < 0) {}
    

    1. UWP / WinUI 3

    // WinUI / UWP / Windows App SDK 1.x
    Window.Current.CoreWindow.PointerCursor = null;          // Hide
    Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 0); // Show
    

    (Internally, that wraps the same user32 functionality, but scoped to your app’s CoreWindow.)


    1. Game engines & DirectX

    • DirectX Tool Kit (and most game engines) simply call ShowCursor or SetCursor internally.
    • If you use Raw Input, DirectXInput, SDL, etc., they typically expose their own wrapper (SDL_ShowCursor, IDeviceResources::ShowCursor, etc.), which ultimately call the same Win32 API.


    TL;DR – Yes, Windows 10 and Windows 11 expose an official API: user32!ShowCursor, plus helpers like SetCursor(NULL).
    – You have language-specific wrappers in .NET, WPF, and UWP/WinUI.
    – The behavior is process/window-scoped; you cannot permanently hide the system cursor for other apps without elevated, undocumented tricks (and Microsoft doesn’t want you to).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.