Exemplo n.º 1
0
        /// <summary>
        /// Clips the or center window to monitor.
        /// </summary>
        /// <param name="handle">The HWND.</param>
        /// <param name="mi">The mi.</param>
        /// <param name="flags">The flags.</param>
        public static void ClipOrCenterWindowToMonitor(IntPtr handle, MONITORINFO mi, UInt32 flags)
        {
            var windowArea = new RECT();

            NativeMonitorHelper.GetWindowRect(handle, ref windowArea);
            ClipOrCenterRectToMonitor(ref windowArea, mi, flags);
            WindowHelper.SetWindowPos(handle, WindowZOrder.HWND_TOP, windowArea.left, windowArea.top,
                                      0, 0, WindowsPosition.SWP_NOSIZE | WindowsPosition.SWP_NOZORDER | WindowsPosition.SWP_NOACTIVATE);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Monitors the enum.
        /// </summary>
        /// <param name="hMonitor">The h monitor.</param>
        /// <param name="hdcMonitor">The HDC monitor.</param>
        /// <param name="lprcMonitor">The LPRC monitor.</param>
        /// <param name="dwData">The dw data.</param>
        /// <returns></returns>
        public static bool MonitorEnum(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData)
        {
            var mi = new MONITORINFO();

            mi.size = (uint)Marshal.SizeOf(mi);
            NativeMonitorHelper.GetMonitorInfo(hMonitor, ref mi);

            // Add to monitor info
            _monitorInfos.Add(new MonitorInfoWithHandle(hMonitor, mi));
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the monitors.
        /// </summary>
        /// <returns></returns>
        public static MonitorInfoWithHandle[] GetMonitors()
        {
            // New List
            _monitorInfos = new List <MonitorInfoWithHandle>();

            // Enumerate monitors
            NativeMonitorHelper.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, MonitorEnum, IntPtr.Zero);

            // Return list
            return(_monitorInfos.ToArray());
        }