I want to detect on which screen a window is displayed when I got its handle. I found a SetWindowPos() function in Win API, but unfortunately there is no GetWindowPos() just a GetWindowRect(), but this results some odd values.
I got two devices, left one 1280×1024 and right one (primary) 1680×1050. When I want to get the position of a minimized firefox, I get b/l/r/t -31973/-32000/-31840/-32000 for either screen.
How do I know that it is my left or my right screen?
WinAPI has a
MonitorFromRectfunction, which is probably what you need. I’m not sure if there’s a C# equivalent, but you can call it through interop.Be aware that the window can be on both monitors, or on neither. The API has flags for that, e.g.
MONITOR_DEFAULTTONEAREST.