Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event for when the number of displays changes in .NET?

I have a program that needs to update some internal data structures when the number of attached displays changes, like when you put your laptop into the docking station and your dual monitors comes to life.

Couple of questions in this regard:

  • Is there such an event in .NET?
  • If not, is there a windows message I can listen for?
  • Will Screen.AllScreens be updated?
  • Will it be updated before I catch the event? or after? or is that indeterminate?

If it matters, this is .NET 3.5 and C#.

like image 369
Lasse V. Karlsen Avatar asked Sep 19 '25 03:09

Lasse V. Karlsen


1 Answers

Have you looked into SystemEvents.DisplaySettingsChanged Event:

Occurs when the user changes the display settings.

There's not much more information than this on the MSDN but it might be of some use.

like image 200
ChrisF Avatar answered Sep 20 '25 17:09

ChrisF