Answer the question
In order to leave comments, you need to log in
How to find out the number of the desktop on which the window?
How to find out from the win forms window on which desktop by number it is located in Windows?
Is there an event that the window has moved to another desktop?
Answer the question
In order to leave comments, you need to log in
If you need exactly the monitor number, and not the desktop, then you need the System.Windows.Forms.Screen class, which has a lot of useful things. For example, Screen.FromControl()
, Screen.FromHandle()
etc. Or you can use the AllScreens property, which stores all monitors in the system.
There is a nuance here - FromHandle does not take the top left point of the window, but the middle of the top border of the window. See what you need.
And one more nuance - the monitor numbers in the AllScreens list may not match the monitor number in the Windows screen settings. I could not find this Windows monitor number. Windows numbers depend on the video card port to which they are connected.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question