Help me gather info about multiple monitors
-
Hi, I'm creating code to select monitor in a multi-monitor configuration. I was wondering if someone with many monitors could help me understand what is happening once you have 5-6 monitors connected to your PC by running this script and just reporting results it prints out.
using System;
using System.Drawing;
using System.Windows.Forms;namespace Scr.Tests
{
class Program
{
static void Main(string[] args)
{
Rectangle desktop = SystemInformation.VirtualScreen;
Console.WriteLine(desktop.ToString());Screen\[\] screens = Screen.AllScreens; for (int i = 0; i < screens.Length; i++) { Console.WriteLine(screens\[i\].Bounds.ToString()); // Total. Console.WriteLine(screens\[i\].DeviceName); Console.WriteLine(screens\[i\].WorkingArea.ToString()); // Total minus system usage i.e. taskbar. } } }
}
Sincerely, Tomaz
-
Hi, I'm creating code to select monitor in a multi-monitor configuration. I was wondering if someone with many monitors could help me understand what is happening once you have 5-6 monitors connected to your PC by running this script and just reporting results it prints out.
using System;
using System.Drawing;
using System.Windows.Forms;namespace Scr.Tests
{
class Program
{
static void Main(string[] args)
{
Rectangle desktop = SystemInformation.VirtualScreen;
Console.WriteLine(desktop.ToString());Screen\[\] screens = Screen.AllScreens; for (int i = 0; i < screens.Length; i++) { Console.WriteLine(screens\[i\].Bounds.ToString()); // Total. Console.WriteLine(screens\[i\].DeviceName); Console.WriteLine(screens\[i\].WorkingArea.ToString()); // Total minus system usage i.e. taskbar. } } }
}
Sincerely, Tomaz
Your question is not clear here. What is about what is "printed out" by your code that you don't understand. Given the information produced by enumerating the Screens, what is you want to do ? Given that more than one Screen can have (one or more) TaskBar objects, what does that mean in this context. You are aware that 'ScreenPrimaryScreen() will return the current active device Window, and if you are enumerating multiple Screens, the Screen.Primary method will return a boolean value for a given Screen indicating whether it's Primary. In any case, I think there's code on this post, and on this thread, on StackOverFlow you may find useful: [^]
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
-
Your question is not clear here. What is about what is "printed out" by your code that you don't understand. Given the information produced by enumerating the Screens, what is you want to do ? Given that more than one Screen can have (one or more) TaskBar objects, what does that mean in this context. You are aware that 'ScreenPrimaryScreen() will return the current active device Window, and if you are enumerating multiple Screens, the Screen.Primary method will return a boolean value for a given Screen indicating whether it's Primary. In any case, I think there's code on this post, and on this thread, on StackOverFlow you may find useful: [^]
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
Short answer is: I would like to draw monitor configuration on screen and I need test data sample to be able to resolve my dilemmas: - which monitor is monitor 1 (is it always left, top?), - can coordinates be negative, - what if one monitor is "missiong" and hence rectangular virtual desktop has "holes" in it, how does mouse behave then, ... Configurations such as this one: https://s-media-cache-ak0.pinimg.com/736x/c4/2f/90/c42f908f046399f8d097a7ecc6cf8bf4.jpg[^] are not that uncommon in the financial industry anymore. And my apps must follow the trend. So I really need a printout of this program. Then I can use the coordinates in my test program to simulate multi- monitor environment and draw it correctly.
-
Short answer is: I would like to draw monitor configuration on screen and I need test data sample to be able to resolve my dilemmas: - which monitor is monitor 1 (is it always left, top?), - can coordinates be negative, - what if one monitor is "missiong" and hence rectangular virtual desktop has "holes" in it, how does mouse behave then, ... Configurations such as this one: https://s-media-cache-ak0.pinimg.com/736x/c4/2f/90/c42f908f046399f8d097a7ecc6cf8bf4.jpg[^] are not that uncommon in the financial industry anymore. And my apps must follow the trend. So I really need a printout of this program. Then I can use the coordinates in my test program to simulate multi- monitor environment and draw it correctly.
To get the type of information you mention, I think you'll have to use the MonitorInfo API call 'GetMonitorInfo, and examine the state of the 'MONITORINFO or MONITORINFOEX structures it returns: [^]. This may be useful: [^].
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008