Ejemplo n.º 1
0
 public static string DevmodeToString(Devmode devMode)
 {
     return(devMode.DMPelsWidth +
            " x " + devMode.DMPelsHeight +
            ", " + devMode.DMBitsPerPel +
            " bits, " +
            devMode.DMDisplayFrequency + " Hz");
 }
Ejemplo n.º 2
0
        public static Devmode GetDevmode(int devNum, int modeNum)
        {
            var devMode = new Devmode();
            var devName = GetDeviceName(devNum);

            NativeMethods.EnumDisplaySettings(devName, modeNum, ref devMode);
            return(devMode);
        }
Ejemplo n.º 3
0
 public static void ChangeResolutionMode(int devNum, Devmode mode)
 {
     if (mode.DMBitsPerPel != 0 && mode.DMPelsWidth != 0 && mode.DMPelsHeight != 0)
     {
         var result = NativeMethods.ChangeDisplaySettingsEx(GetDeviceName(devNum), ref mode, IntPtr.Zero, 0, IntPtr.Zero);
         if (result > 0)
         {
             return;
         }
     }
 }
Ejemplo n.º 4
0
        public static Devmode[] EnumModes(int devNum)
        {
            var  modes   = new ArrayList();
            var  devName = GetDeviceName(devNum);
            var  devMode = new Devmode();
            var  modeNum = 0;
            bool result;

            do
            {
                result = NativeMethods.EnumDisplaySettings(devName, modeNum, ref devMode);
                if (result)
                {
                    modes.Add(devMode);
                }
                modeNum++;
            } while (result);

            return((Devmode[])modes.ToArray(typeof(Devmode)));
        }
Ejemplo n.º 5
0
 public static extern int ChangeDisplaySettingsEx(
     string devName, ref Devmode devMode, IntPtr hwnd, int dwFlags, IntPtr lParam);
Ejemplo n.º 6
0
 public static extern bool EnumDisplaySettings(
     string devName, int modeNum, ref Devmode devMode);
Ejemplo n.º 7
0
 public ScreenRes(Devmode mode)
 {
     Mode = mode;
 }