microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.35k stars 678 forks source link

ShowCursor(false) doesn't work. Window not created on UI thread? #10128

Closed tom-huntington closed 1 hour ago

tom-huntington commented 3 hours ago

Describe the bug

I cant hide the cursor with ShowCursor

During the conversion to Win32, the cursor show counter became a thread-local state. (Naturally, multiple threads could merge their cursor show counters by attachment.) Consequently, when a thread calls ShowCursor it affects the cursor show state only for windows that belong to that thread.

https://devblogs.microsoft.com/oldnewthing/20091217-00

This suggests the UI thread was not used to create the window.

Steps to reproduce the bug

https://github.com/tom-huntington/ShowCursorMRE

Expected behavior

I expect some way to hide the cursor

NuGet package version

WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002

Windows version

Windows 11 (21H2): Build 22000

castorix commented 2 hours ago

ShowCursor is for Win32 cursors You can change/hide cursor for XAML UIElements with ProtectedCursor (threads like https://github.com/microsoft/WindowsAppSDK/discussions/1816, https://github.com/microsoft/WindowsAppSDK/discussions/3601, ...)