internal Screen(IntPtr monitor, IntPtr hdc) { this.workingArea = Rectangle.Empty; this.currentDesktopChangedCount = -1; IntPtr handle = hdc; if (!multiMonitorSupport || (monitor == ((IntPtr) (-1163005939)))) { this.bounds = SystemInformation.VirtualScreen; this.primary = true; this.deviceName = "DISPLAY"; } else { System.Windows.Forms.NativeMethods.MONITORINFOEX info = new System.Windows.Forms.NativeMethods.MONITORINFOEX(); System.Windows.Forms.SafeNativeMethods.GetMonitorInfo(new HandleRef(null, monitor), info); this.bounds = Rectangle.FromLTRB(info.rcMonitor.left, info.rcMonitor.top, info.rcMonitor.right, info.rcMonitor.bottom); this.primary = (info.dwFlags & 1) != 0; for (int i = info.szDevice.Length; (i > 0) && (info.szDevice[i - 1] == '\0'); i--) { } this.deviceName = new string(info.szDevice); this.deviceName = this.deviceName.TrimEnd(new char[1]); if (hdc == IntPtr.Zero) { handle = System.Windows.Forms.UnsafeNativeMethods.CreateDC(this.deviceName); } } this.hmonitor = monitor; this.bitDepth = System.Windows.Forms.UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, handle), 12); this.bitDepth *= System.Windows.Forms.UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, handle), 14); if (hdc != handle) { System.Windows.Forms.UnsafeNativeMethods.DeleteDC(new HandleRef(null, handle)); } }
internal Screen(IntPtr monitor, IntPtr hdc) { this.workingArea = Rectangle.Empty; this.currentDesktopChangedCount = -1; IntPtr handle = hdc; if (!multiMonitorSupport || (monitor == ((IntPtr)(-1163005939)))) { this.bounds = SystemInformation.VirtualScreen; this.primary = true; this.deviceName = "DISPLAY"; } else { System.Windows.Forms.NativeMethods.MONITORINFOEX info = new System.Windows.Forms.NativeMethods.MONITORINFOEX(); System.Windows.Forms.SafeNativeMethods.GetMonitorInfo(new HandleRef(null, monitor), info); this.bounds = Rectangle.FromLTRB(info.rcMonitor.left, info.rcMonitor.top, info.rcMonitor.right, info.rcMonitor.bottom); this.primary = (info.dwFlags & 1) != 0; for (int i = info.szDevice.Length; (i > 0) && (info.szDevice[i - 1] == '\0'); i--) { } this.deviceName = new string(info.szDevice); this.deviceName = this.deviceName.TrimEnd(new char[1]); if (hdc == IntPtr.Zero) { handle = System.Windows.Forms.UnsafeNativeMethods.CreateDC(this.deviceName); } } this.hmonitor = monitor; this.bitDepth = System.Windows.Forms.UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, handle), 12); this.bitDepth *= System.Windows.Forms.UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, handle), 14); if (hdc != handle) { System.Windows.Forms.UnsafeNativeMethods.DeleteDC(new HandleRef(null, handle)); } }
public static extern bool GetMonitorInfo(HandleRef hmonitor, [In, Out] System.Windows.Forms.NativeMethods.MONITORINFOEX info);