Exemplo n.º 1
0
 public void UpdateMonitors()
 {
     FreeMonitors();
     WindowsAPI.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, delegate(
         IntPtr hMonitor,
         IntPtr hdcMonitor,
         ref RECT lprcMonitor,
         IntPtr dwData)
     {
         MonitorDevice mi = new MonitorDevice();
         mi.handle = hMonitor;
         mi.index = listMonitors.Count;
         listMonitors.Add(mi);
         return true;
     }, IntPtr.Zero);
 }
Exemplo n.º 2
0
 public void UpdateMonitors()
 {
     FreeMonitors();
     WindowsAPI.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, delegate(
         IntPtr hMonitor,
         IntPtr hdcMonitor,
         ref RECT lprcMonitor,
         IntPtr dwData)
     {
         MonitorDevice mi = new MonitorDevice();
         mi.handle = hMonitor;
         mi.index = listMonitors.Count;
         listMonitors.Add(mi);
         return true;
     }, IntPtr.Zero);
 }
Exemplo n.º 3
0
 public bool FullScreenWindow(IntPtr hWnd, int iMonitorIndex = 0)
 {
     if (hWnd == IntPtr.Zero || !WindowsAPI.IsWindow(hWnd))
     {
         return false;
     }
     MonitorDevice md = GetMonitor(iMonitorIndex);
     if (md.handle != IntPtr.Zero)
     {
         Rect rc = md.GetMonitorRect();
         WindowsAPI.SetWindowPos(
             hWnd,
             IntPtr.Zero,
             (int)rc.Left,
             (int)rc.Top,
             (int)rc.Width,
             (int)rc.Height,
             CommonConst.SWP_SHOWWINDOW | CommonConst.SWP_FRAMECHANGED | CommonConst.SWP_NOZORDER);
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
        public bool CenterWindow(IntPtr hWnd, int iMonitorIndex = 0, bool bUseWorkArea = false)
        {
            RECT srect = new RECT();
            WindowsAPI.GetWindowRect(hWnd, ref srect);
            Rect rect = new Rect(srect.left, srect.top, srect.right - srect.left, srect.bottom - srect.top);

            if (0 > iMonitorIndex)
            {
                rect = CenterWindowToAll(rect, bUseWorkArea);
            }
            else if (0 == iMonitorIndex)
            {
                MonitorDevice pMonitor = GetNearestMonitor(hWnd);
                if (pMonitor.handle == IntPtr.Zero)
                {
                    return false;
                }
                rect = pMonitor.CenterRectToMonitor(rect, bUseWorkArea);
            }
            else
            {
                MonitorDevice pMonitor = GetMonitor(iMonitorIndex);
                if (pMonitor.handle == IntPtr.Zero)
                {
                    return false;
                }
                rect = pMonitor.CenterRectToMonitor(rect, bUseWorkArea);
            }
            return WindowsAPI.SetWindowPos(
                hWnd,
                IntPtr.Zero,
                (int)rect.Left,
                (int)rect.Top,
                0,
                0,
                CommonConst.SWP_NOSIZE | CommonConst.SWP_NOZORDER);
        }