private static List <DisplayInfo> GetDisplays() { List <DisplayInfo> displayCollection = new List <DisplayInfo>(); MonitorEnumDelegate monitorDelegate = delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData) { MonitorInfoEx monitorInfo = new MonitorInfoEx(); monitorInfo.size = (uint)Marshal.SizeOf(monitorInfo); if (GetMonitorInfo(hMonitor, ref monitorInfo)) { var info = new DevMode(); EnumDisplaySettings(monitorInfo.deviceName, -1, ref info); var monitor = new Rect { left = info.dmPositionX, right = info.dmPositionX + info.dmPelsWidth, top = info.dmPositionY, bottom = info.dmPositionY + info.dmPelsHeight }; DisplayInfo displayInfo = new DisplayInfo(monitor, monitorInfo.flags); displayCollection.Add(displayInfo); } return(true); }; EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, monitorDelegate, IntPtr.Zero); return(displayCollection); }
public static bool procMonitor() { int monCount = 0; MonitorInfo mi = new MonitorInfo(); mi.size = Marshal.SizeOf(typeof(MonitorInfo)); List <MonitorInfo> monitors = new List <MonitorInfo>(); MonitorEnumDelegate MonitorProc = (IntPtr hDesktop, IntPtr hdc, ref Rect lprcMonitor, int d) => { monCount++; if (GetMonitorInfo(hDesktop, mi)) { monitors.Add(mi); Console.WriteLine("name"); Console.WriteLine(mi.work.bottom + "x" + mi.work.right); } return(true); }; if (EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, MonitorProc, 0)) { Console.WriteLine("You have {0} monitors", monCount); } else { Console.WriteLine("An error occured while enumerating monitors"); } return(EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, MonitorProc, 0)); //return true; }
private ReadStatus ReadMonitors() { monitorRectsList = new List <Rect>(); MonitorEnumDelegate med = new MonitorEnumDelegate(MonitorEnum); EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, med, IntPtr.Zero); return(monitorRectsList.Count > 0 ? ReadStatus.Success : ReadStatus.Failure); }
public static List <MonitorInfo> GetMonitors() { List <MonitorInfo> result = new List <MonitorInfo>(); MonitorEnumDelegate med = (IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData) => { var minfo = GetMonitorInfo(hMonitor); result.Add(minfo); return(true); }; Monitors.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, med, IntPtr.Zero); return(result); }
private static List <DisplayInfo> GetDisplays() { List <DisplayInfo> displayCollection = new List <DisplayInfo>(); MonitorEnumDelegate monitorDelegate = delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData) { MonitorInfo monitorInfo = new MonitorInfo(); monitorInfo.size = (uint)Marshal.SizeOf(monitorInfo); if (GetMonitorInfo(hMonitor, ref monitorInfo)) { DisplayInfo displayInfo = new DisplayInfo(monitorInfo.monitor, monitorInfo.work, monitorInfo.flags); displayCollection.Add(displayInfo); } return(true); }; EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, monitorDelegate, IntPtr.Zero); return(displayCollection); }
public static IEnumerable <MonitorInformation> GetAllMonitors() { var monitors = new List <MonitorInformation>(); MonitorEnumDelegate callback = delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData) { MONITORINFOEX mi = new MONITORINFOEX(); mi.cbSize = Marshal.SizeOf(typeof(MONITORINFOEX)); if (!GetMonitorInfo(hMonitor, ref mi)) { throw new Win32Exception(); } monitors.Add(new MonitorInformation(mi)); return(true); }; EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, callback, IntPtr.Zero); return(monitors); }
public static List <MONITORINFO> GetDisplays() { var tmp = new List <MONITORINFO>(); MonitorEnumDelegate callback = (IntPtr hDesktop, IntPtr hdc, ref RECT rect, int d) => { MONITORINFO info = new MONITORINFO(); bool isok = GetMonitorInfo(hDesktop, info); if (isok) { tmp.Add(info); } return(true); }; if (EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, callback, 0)) { return(tmp); } return(null); }
public static extern Boolean EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData);
public static extern bool EnumDisplayMonitors(IntPtr deviceContext, IntPtr clipRect, MonitorEnumDelegate callback, IntPtr data);
public static void DisplayProperty(ref SearchedDisplay strSD) { retSearchedDisplay = strSD; MonitorEnumDelegate med = new MonitorEnumDelegate(MonitorEnum); EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, med, IntPtr.Zero); strSD = retSearchedDisplay; }
public static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr rect, MonitorEnumDelegate callback, int data);
public void RefreshDisplays() { m_screens.Clear(); MonitorEnumDelegate med = new MonitorEnumDelegate(MonitorEnum); EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, med, IntPtr.Zero); m_desktopBounds = new Rectangle(); foreach (Screen screen in m_screens) { m_desktopBounds = Rectangle.Union(screen.Bounds, m_desktopBounds); } }
public bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData) { return(NativeMethods.EnumDisplayMonitors(hdc, lprcClip, lpfnEnum, dwData)); }
private static extern bool EnumDisplayMonitors(IntPtr displayDeviceContextHandle, IntPtr clipArea, MonitorEnumDelegate callback, IntPtr callbackData);
private static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData);
public static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData);
public static extern bool EnumDisplayMonitors(IntPtr hDC, IntPtr lpRect, MonitorEnumDelegate callback, int dwData);