Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help me gather info about multiple monitors

Help me gather info about multiple monitors

Scheduled Pinned Locked Moved C#
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tomaz Stih 0
    wrote on last edited by
    #1

    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

    B 1 Reply Last reply
    0
    • T Tomaz Stih 0

      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

      B Offline
      B Offline
      BillWoodruff
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • B BillWoodruff

        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

        T Offline
        T Offline
        Tomaz Stih 0
        wrote on last edited by
        #3

        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.

        B 1 Reply Last reply
        0
        • T Tomaz Stih 0

          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.

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups