You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm making a presentation application, and I need to update the UI when an external monitor is connected or disconnected. For this I have implemented DisplayAreaWatcher where I listen for Added and Removed events. These events are not triggered when I connect or disconnect physical monitors to the PC while the application is running.
Please let me know if I'm using the wrong method and if there is a better way to detect when monitors are connected and disconnected
Steps to reproduce the bug
Create a new WinUI3 application
In the MainWindow class add a new DisplayAreaWatcher and subscribe to Added and Removed events with printouts to the debug console.
Run the application on a laptop not connected to an external montor.
Watch that the Added event is triggered during startup
Connect an external monitor
Observe that no Added event is triggered
Disconnect the external monitor
Observe that on Removed event is triggered
Expected behavior
I expected that if I connect an external monitor to the PC while the application was running an Added event would be triggered. I also expected that if I disconnected an external monitor from the PC while the application was running a Removed event would be triggered.
Screenshots
No response
NuGet package version
Windows App SDK 1.4.3: 1.4.231115000
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
Note that I'm running Windows 11 Pro 23H2, but that is not an option in the Windows version selector above
The text was updated successfully, but these errors were encountered:
When the monitor-configuration changes EnterContextAndProcessDisplayAreaWatcherMessage gets called but fails to decode the handle of the watcher (Core::Util::DecodeHandle throws an exception).
Therefore Windowing::DisplayAreaWatcher::OnDisplayChange is never called.
Exception
Exception thrown at 0x00007FFF681EF39C (KernelBase.dll) in ShortDev.Windows.Shell.exe: WinRT originate error - 0x80070006 : Invalid Handle.'.
Exception thrown at 0x00007FFF681EF39C in ShortDev.Windows.Shell.exe: Microsoft C++ exception: Core::ApiException::Holder$ at memory location 0x000000ADECB7DE48.
Describe the bug
I'm making a presentation application, and I need to update the UI when an external monitor is connected or disconnected. For this I have implemented DisplayAreaWatcher where I listen for Added and Removed events. These events are not triggered when I connect or disconnect physical monitors to the PC while the application is running.
I have made a test application that shows the issue: https://github.com/torfluor/DisplayAreaWatcherTest
Please let me know if I'm using the wrong method and if there is a better way to detect when monitors are connected and disconnected
Steps to reproduce the bug
Expected behavior
I expected that if I connect an external monitor to the PC while the application was running an Added event would be triggered. I also expected that if I disconnected an external monitor from the PC while the application was running a Removed event would be triggered.
Screenshots
No response
NuGet package version
Windows App SDK 1.4.3: 1.4.231115000
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
Note that I'm running Windows 11 Pro 23H2, but that is not an option in the Windows version selector above
The text was updated successfully, but these errors were encountered: