c# - Available Resolutions For a specific Screen -


i might have 2 monitor/screens connected machine. want know avaliable resolutions specific screen (i have instance of type system.windows.forms.screen).

i've seen following: how list available video modes using c#?

list of valid resolutions given screen?

but give results monitors , not specific one. suggestions? thanks!!!

edit 1: enter image description here

this info 2 screens: enter image description here

in first of links you're told enumdisplaysettings. take few seconds lookup function , first parameter

string specifies display device graphics mode function obtain information.

here's sample class fetch information displays. i've deliberately omitted devmode since you've got it.

public class nativemethods {     [dllimport("user32.dll")]     public static extern bool enumdisplaysettings(string devicename, int modenum, ref devmode devmode);     [dllimport("user32.dll")]     public static extern bool enumdisplaydevices(string devicename, int modenum, ref display_device displaydevice, int flags); }   [structlayout(layoutkind.sequential)] public struct display_device {     public int cb;     [marshalas(unmanagedtype.byvaltstr, sizeconst = 32)]     public string devicename;     [marshalas(unmanagedtype.byvaltstr, sizeconst = 128)]     public string devicestring;     public int stateflags;     [marshalas(unmanagedtype.byvaltstr, sizeconst = 128)]     public string deviceid;     [marshalas(unmanagedtype.byvaltstr, sizeconst = 128)]     public string devicekey; }  static class display {     public static list<display_device> getgraphicsadapters()     {         int = 0;         display_device displaydevice = new display_device();         list<display_device> result = new list<display_device>();         displaydevice.cb = marshal.sizeof(displaydevice);         while (nativemethods.enumdisplaydevices(null, i, ref displaydevice, 1))         {             result.add(displaydevice);             i++;         }          return result;     }      public static list<display_device> getmonitors(string graphicsadapter)     {          display_device displaydevice = new display_device();         list<display_device> result = new list<display_device>();         int = 0;         displaydevice.cb = marshal.sizeof(displaydevice);         while (nativemethods.enumdisplaydevices(graphicsadapter, i, ref displaydevice, 0))         {             result.add(displaydevice);             i++;         }          return result;     }      public static list<devmode> getdevicemodes(string graphicsadapter)     {         int = 0;         devmode devmode = new devmode();         list<devmode> result = new list<devmode>();         while (nativemethods.enumdisplaysettings(graphicsadapter, i, ref devmode))         {             result.add(devmode);             i++;         }         return result;     } } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -