Ejemplo n.º 1
0
        internal Screen(IntPtr monitor, IntPtr hdc)
        {
            IntPtr screenDC = hdc;

            if (!multiMonitorSupport || monitor == (IntPtr)PRIMARY_MONITOR)
            {
                // Single monitor system
                bounds     = new Rectangle(new Point(0, 0), PrimaryMonitorSize);
                primary    = true;
                deviceName = "DISPLAY";
            }
            else
            {
                var info = new MonitorInfoEx(); info.Init();
                WinMethods.GetMonitorInfo(ToHR(monitor), ref info);
                bounds     = info.Monitor;             //implicit conversion
                primary    = ((info.Flags & MONITORINFOF_PRIMARY) != 0);
                deviceName = new string(info.DeviceName);
                deviceName = deviceName.TrimEnd((char)0);

                if (hdc == IntPtr.Zero)
                {
                    screenDC = WinMethods.CreateDC(deviceName, null, null, IntPtr.Zero);
                }
            }
            hmonitor = monitor;

            this.bitDepth  = WinMethods.GetDeviceCaps(ToHR(screenDC), DeviceCap.BITSPIXEL);
            this.bitDepth *= WinMethods.GetDeviceCaps(ToHR(screenDC), DeviceCap.PLANES);
            this.vRfresh   = WinMethods.GetDeviceCaps(ToHR(screenDC), DeviceCap.VREFRESH);
            this.pWidthMm  = WinMethods.GetDeviceCaps(ToHR(screenDC), DeviceCap.HORZSIZE);
            this.pHeightMm = WinMethods.GetDeviceCaps(ToHR(screenDC), DeviceCap.VERTSIZE);

            if (hdc != screenDC)
            {
                WinMethods.DeleteDC(ToHR(screenDC));
            }
        }