Пример #1
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);
        }
Пример #2
0
 public static extern bool ExtTextOut(IntPtr hdc, int X, int Y, uint fuOptions, ref RECT lprc, string lpString, uint cbCount, int[] lpDx);
Пример #3
0
 public static extern int DrawTextEx(IntPtr hdc, string lpchText, int cchText, RECT lprc, uint dwDTFormat, DRAWTEXTPARAMS lpDTParams);
Пример #4
0
 public static extern bool InvalidateRect(int hWnd, ref RECT lpRect, bool bErase);
Пример #5
0
 public static extern int DrawText(IntPtr hDC, string lpString, int nCount, ref RECT lpRect, uint uFormat);
Пример #6
0
 public static extern bool IsRectEmpty(ref RECT lprc);
Пример #7
0
 public static extern bool OffsetRect(ref RECT lprc, int dx, int dy);
Пример #8
0
 public static extern bool CopyRect(string lprcDst, ref RECT lprcSrc);
Пример #9
0
 public static extern IntPtr GetDCEx(IntPtr hWnd, RECT hrgnClip, int flags);
Пример #10
0
 public static extern int FillRect(IntPtr hDC, ref RECT lprc, IntPtr hbr);
Пример #11
0
 public static extern int TileWindows(IntPtr hwndParent, uint wHow, ref RECT lpRect, uint cKids, IntPtr lpKids);
Пример #12
0
 public static extern bool GetClipCursor(ref RECT lpRect);
Пример #13
0
 public static extern bool AdjustWindowRectEx(RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
Пример #14
0
 public static extern bool AdjustWindowRect(ref RECT lpRect, int dwStyle, bool bMenu);
Пример #15
0
 public static extern bool GetClientRect(IntPtr hWnd, ref RECT lpRect);
Пример #16
0
 public static extern bool GetWindowRect(IntPtr handle, ref RECT lpRect);