public DEVMODE GetDevmodeFor(int devNum, int width, int height)
        {
            DEVMODE current = GetCurrentSettings(devNum);
            string  devName = GetDeviceName(devNum);
            DEVMODE devMode = new DEVMODE();
            int     modeNum = 0;
            bool    result  = true;

            do
            {
                result = EnumDisplaySettings(devName,
                                             modeNum, ref devMode);

                if (result)
                {
                    if (devMode.dmPelsWidth == width && devMode.dmPelsHeight == height && devMode.dmBitsPerPel == current.dmBitsPerPel)
                    {
                        return(devMode);
                    }
                }
                modeNum++;
            } while (result);
            return(current);
        }
 private static extern bool EnumDisplaySettings(
     string devName, int modeNum, ref DEVMODE devMode);
 public static extern int ChangeDisplaySettings(
     ref DEVMODE devMode, int flags);
示例#4
0
 public FormState()
 {
     Settings    = new DisplaySettings();
     orginalMode = Settings.GetCurrentSettings(0);
 }