Currently, you can see more and more people working in offices on two or more monitors. Such work is more convenient and efficient. As a developer I would not be able to change back to one monitor. Therefore I see no contraindications, to write their own applications in a way, for working on multiple monitors. Of course this is not always feasible.
Before I wrote my first application that uses multiple monitors, I was wondering how much functionality you need to write complex, application began to behave as I want. It turned out, that the effort is minimal. Generally, the creation of such an application consists of two steps:
- examine the system and determine how many monitors we have and what resolution offer,
- a prompt us interesting things at the appropriate monitor.
The first part can be done in two ways. Information on the monitors can be obtained by using two classes:
- SystemInformation
- Screen
Experience shows, from both classes give the same results. However, always use the proposed class Screen. According to MSDN ownership SystemInformation. MonitorCount is supported only on Windows 98, Windows ME, Windows 2000, Windows XP i Windows 2003. There can be no information, animals or Windows Vista, animals or Windows 7. By checking this on the available machines, always obtain the same results, but always the final code I use the Screen class. Just in case.
Call up for SystemInformation:
System.Console.WriteLine("Primary screen resolution: " + SystemInformation.PrimaryMonitorSize); System.Console.WriteLine("Virtual size: " + SystemInformation.VirtualScreen); System.Console.WriteLine("Monitors count: " + SystemInformation.MonitorCount);
Call up for Screen:
foreach (Screen screen in Screen.AllScreens) { System.Console.WriteLine("Primary: " + screen.Primary); System.Console.WriteLine("Resolution: " + screen.Bounds); System.Console.WriteLine("Working area: " + screen.WorkingArea); System.Console.WriteLine("Device name: " + screen.DeviceName); System.Console.WriteLine(); }
The second element is the control displaying the, or other UI element in place, we want. In this case, everything depends on us. Generally, the code looks like this:
Form1 form1 = new Form1(); int controlPossition = 0; if (Screen.AllScreens.Length > 1) { foreach (Screen screen in Screen.AllScreens) { if (!screen.Primary) { controlPossition = screen.Bounds.X; break; } } form1.Left = controlPossition; form1.StartPosition = FormStartPosition.Manual; } form1.Show();
Keep in mind, with the controllers on a computer can be more than two monitors, and, There may be the only one monitor. Additionally, for may be, that even if they are plugged in only two monitors, they do not stand side by side, but a second. Therefore, this code must modify some.
I hope, I managed to show, with writing the application is actively using two monitors at the same time is not complicated and does not significantly increases the amount of work in the project.
świetnym rozwiązaniem jest ‘odpinanie’ części aplikacji, tak jak to oferuje Visual 2010 😉