/// <summary> /// Returns a list of available display modes. (No modes that are smaller than 640x480/60 Hz and less bit depth then the current mode will be returned.) /// </summary> /// <returns>The available display modes as list of <see cref="DisplayMode"/> objects.</returns> public static List <DisplayMode> GetDisplayModes() { List <DisplayMode> displayModes = new List <DisplayMode>(); DevMode displayMode = new DevMode(); uint modeNumber = 0; displayMode.dmSize = (ushort)Marshal.SizeOf(displayMode); EnumDisplaySettings(null, DisplaySettingsMode.ENUM_CURRENT_SETTINGS, ref displayMode); uint currentBitDepth = displayMode.dmBitsPerPel; displayModes.Add(new DisplayMode(displayMode.dmPelsWidth, displayMode.dmPelsHeight, currentBitDepth, displayMode.dmDisplayFrequency)); while (EnumDisplaySettings(null, modeNumber++, ref displayMode)) { if (displayMode.dmPelsWidth >= 640 && displayMode.dmPelsHeight >= 480 && displayMode.dmBitsPerPel == currentBitDepth && displayMode.dmDisplayFrequency >= 60) { displayModes.Add(new DisplayMode(displayMode.dmPelsWidth, displayMode.dmPelsHeight, currentBitDepth, displayMode.dmDisplayFrequency)); } } return(displayModes); }
public static extern DISP_CHANGE ChangeDisplaySettingsEx(string lpszDeviceName, ref DevMode lpDevMode, HWND hwnd, CDS dwflags, IntPtr lParam);
public static extern DISP_CHANGE ChangeDisplaySettings(ref DevMode lpDevMode, CDS dwflags);
public static extern bool EnumDisplaySettings(string lpszDeviceName, uint iModeNum, ref DevMode lpDevMode);
public static extern bool EnumDisplaySettingsEx(string lpszDeviceName, uint iModeNum, ref DevMode lpDevMode, EDS dwFlags);
public static extern DISP_CHANGE ChangeDisplaySettingsEx(string lpszDeviceName, ref DevMode lpDevMode, HWND hwnd, CDS dwflags, IntPtr lParam);
public static extern DISP_CHANGE ChangeDisplaySettings(ref DevMode lpDevMode, CDS dwflags);
/// <summary> /// Returns a list of available display modes. (No modes that are smaller than 640x480/60 Hz and less bit depth then the current mode will be returned.) /// </summary> /// <returns>The available display modes as list of <see cref="DisplayMode"/> objects.</returns> public static List<DisplayMode> GetDisplayModes() { List<DisplayMode> displayModes=new List<DisplayMode>(); DevMode displayMode=new DevMode(); uint modeNumber=0; displayMode.dmSize=(ushort)Marshal.SizeOf(displayMode); EnumDisplaySettings(null, DisplaySettingsMode.ENUM_CURRENT_SETTINGS, ref displayMode); uint currentBitDepth=displayMode.dmBitsPerPel; displayModes.Add(new DisplayMode(displayMode.dmPelsWidth, displayMode.dmPelsHeight, currentBitDepth, displayMode.dmDisplayFrequency)); while(EnumDisplaySettings(null, modeNumber++, ref displayMode)) { if(displayMode.dmPelsWidth>=640&&displayMode.dmPelsHeight>=480&&displayMode.dmBitsPerPel==currentBitDepth&&displayMode.dmDisplayFrequency>=60) displayModes.Add(new DisplayMode(displayMode.dmPelsWidth, displayMode.dmPelsHeight, currentBitDepth, displayMode.dmDisplayFrequency)); } return displayModes; }
public static extern bool EnumDisplaySettingsEx(string lpszDeviceName, uint iModeNum, ref DevMode lpDevMode, EDS dwFlags);
public static extern bool EnumDisplaySettings(string lpszDeviceName, uint iModeNum, ref DevMode lpDevMode);