Beispiel #1
0
 public static string DevmodeToString(Devmode devMode)
 {
     return(devMode.DMPelsWidth +
            " x " + devMode.DMPelsHeight +
            ", " + devMode.DMBitsPerPel +
            " bits, " +
            devMode.DMDisplayFrequency + " Hz");
 }
Beispiel #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);
        }
Beispiel #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;
         }
     }
 }
Beispiel #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)));
        }
Beispiel #5
0
 public static extern int ChangeDisplaySettingsEx(
     string devName, ref Devmode devMode, IntPtr hwnd, int dwFlags, IntPtr lParam);
Beispiel #6
0
 public static extern bool EnumDisplaySettings(
     string devName, int modeNum, ref Devmode devMode);
Beispiel #7
0
 public ScreenRes(Devmode mode)
 {
     Mode = mode;
 }