private FREObject SetDisplayResolution(FREContext ctx, uint argc, FREObject[] argv) { var key = argv[0].AsString(); var newWidth = argv[1].AsInt(); var newHeight = argv[2].AsInt(); var newRefreshRate = argv[3].AsInt(); if (string.IsNullOrEmpty(key)) { return(FREObject.Zero); } var device = _displayDeviceMap[key]; var dm = new Devmode(); dm.dmSize = (short)Marshal.SizeOf(dm); if (WinApi.EnumDisplaySettings(device.DeviceName, WinApi.EnumCurrentSettings, ref dm) == 0) { return(false.ToFREObject()); } dm.dmPelsWidth = newWidth; dm.dmPelsHeight = newHeight; var flgs = DevModeFlags.DM_PELSWIDTH | DevModeFlags.DM_PELSHEIGHT; if (newRefreshRate > 0) { flgs |= DevModeFlags.DM_DISPLAYFREQUENCY; dm.dmDisplayFrequency = newRefreshRate; } dm.dmFields = (int)flgs; return(WinApi.ChangeDisplaySettings(ref dm, (int)ChangeDisplaySettingsFlags.CdsTest) != 0 ? false.ToFREObject() : (WinApi.ChangeDisplaySettings(ref dm, 0) == 0).ToFREObject()); }
public FREObject SetDisplayResolution(FREContext ctx, uint argc, FREObject[] argv) { var key = Convert.ToString(new FreObjectSharp(argv[0]).Value); var newWidth = Convert.ToInt32(new FreObjectSharp(argv[1]).Value); var newHeight = Convert.ToInt32(new FreObjectSharp(argv[2]).Value); var newRefreshRate = Convert.ToInt32(new FreObjectSharp(argv[3]).Value); if (!string.IsNullOrEmpty(key)) { var device = _displayDeviceMap[key]; var dm = new Devmode(); dm.dmSize = (short)Marshal.SizeOf(dm); if (WinApi.EnumDisplaySettings(device.DeviceName, WinApi.EnumCurrentSettings, ref dm) == 0) { return(new FreObjectSharp(false).RawValue); } dm.dmPelsWidth = newWidth; dm.dmPelsHeight = newHeight; var flgs = DevModeFlags.DM_PELSWIDTH | DevModeFlags.DM_PELSHEIGHT; if (newRefreshRate > 0) { flgs |= DevModeFlags.DM_DISPLAYFREQUENCY; dm.dmDisplayFrequency = newRefreshRate; } dm.dmFields = (int)flgs; return(WinApi.ChangeDisplaySettings(ref dm, (int)ChangeDisplaySettingsFlags.CdsTest) != 0 ? new FreObjectSharp(false).RawValue : new FreObjectSharp(WinApi.ChangeDisplaySettings(ref dm, 0) == 0).RawValue); } return(FREObject.Zero); }