Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recognize when number, position, or resolution of monitors has changed? [duplicate]

I'm building something which needs to detect when things change with the monitor configuration. This includes Monitor added/removed, Monitor position moved (compared to main screen), or when Monitor resolution has changed. The most ideal way would be catching some windows messages, if any, which are triggered when such events occur. This information will be used to keep a real-time record of the monitor sizes/positions at any given time. For example, when a monitor's resolution is increased, my app will catch this right away and make its own adjustments to accommodate for the change. How do I catch these events?

I'm also trying to avoid using VCL (such as Vcl.Forms.Screen.MonitorCount) which is why I prefer to catch a Windows Message.

like image 685
Jerry Dodge Avatar asked Dec 21 '22 20:12

Jerry Dodge


1 Answers

The most obvious message I can think of is WM_DISPLAYCHANGE which is sent, at least, when the resolution is changed.

like image 103
Andreas Rejbrand Avatar answered Dec 24 '22 00:12

Andreas Rejbrand