0

I have a PC with 3 monitors. Each monitor will display different information.

When I launch my WinForms application, I will query all the displays using Screen.AllScreens, so that I can decide what to shown on which screen.

I always assume the array returned are actually indexed according to the screen number. Means screen 1, following by screen 2 and following by screen 3

It had been running without any problem for the past 10 years, until recently the computer was changed. I found that the index is not always correct. Some times it will return screen 2, screen 1, screen 3.

But at the Display are still showing the correct screen number when we Identify them using Windows 10.

Checking the DeviceName returned by Screen.AllScreens it shows something like \\.\DISPLAY2, \\.\DISPLAY1, \\.\DISPLAY3.

So I guess I need to correlate the DeviceName with the Screen Number. May I know what is the best way? Can I assume the DeviceName always appears as \\.\DISPLAY##, so that I can parse the last digits to decide the Screen Number?

s k
  • 4,342
  • 3
  • 42
  • 61
  • See the notes here: [Using SetWindowPos with multiple monitors](https://stackoverflow.com/a/53026765/7444103) – Jimi Jun 22 '21 at 05:16
  • @Jimi thanks for the link. But I have no problem positioning the display on my screen. I only need to know how to correlate the **Screen Number** with the array returns in ``AllScreens``. – s k Jun 22 '21 at 05:23
  • You can look at the *pictures* :) `Screen.AllScreens` uses [EnumDisplayMonitors(null,null, ..., ...)](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumdisplaymonitors) to return that array. – Jimi Jun 22 '21 at 07:12

0 Answers0