Windows Display Numbering vs Xojo Screen Numbering

Sharing this in case it helps others.

I have an app that assumes it’s main window opens on Screen(0) by default. It needs to open certain other windows on a different, user-selectable screen.

It was working fine on a few setups, but yesterday I added a second monitor to a new workstation and was dismayed to find that Windows had assigned “Display 1” to the new “external” monitor, and the all-in-one PC’s display, where my app will show its main window, was now assigned to Windows display 2. In the screenshot below, the internal display is 2 and the external is 1.

I was concerned that this would break my app and require adding UI and a preference for remembering which screen is “Main”. I scoured the web looking for a way to get Windows to renumber its displays, but despite scores of long threads on the topic, I found no solid solution.

I was relieved then, to find that Xojo happily always assigns Screen(0) to the “Main” screen regardless of Windows’ numbering (yes, I know the docs say it’s the “main” screen, but I still wasn’t sure that it wouldn’t rely on Windows’ idea of “Main”). Here’s Xojo identifying the main screen as Screen(0) (adjusted to 1 for user-friendliness), even though Windows numbers it higher than the other screen. Whew!

Screenshot 2023-11-29 at 5.26.41 PM

I can’t explain that behaviour, my guess is it may have to do with the way Windows works and the monitor interface - HDMI, VGA, etc.

Since Xojo assign Screen(0) to the main screen may be explained by this: did you use the Displays setup to tell Windows which display is the main one, the one that displays the icons to the left of time and date:

? That may explain why it works for you.

1 Like

Yes, from what I gather it’s a bit of a first-come-first-serve situation happening at a very low level in the BIOS. Some people propose registry hacks to change it, other people say that doesn’t work for them, others discuss messing with display adapter settings, etc. Definitely not where I want to go!

Yes, good point! That would explain how Xojo knows which one is “Main” and numbers its Screens() accordingly, thanks!