コード例 #1
0
ファイル: MonitorManager.cs プロジェクト: xxy1991/cozy
        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
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool ExtTextOut(IntPtr hdc, int X, int Y, uint fuOptions, ref RECT lprc, string lpString, uint cbCount, int[] lpDx);
コード例 #3
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern int DrawTextEx(IntPtr hdc, string lpchText, int cchText, RECT lprc, uint dwDTFormat, DRAWTEXTPARAMS lpDTParams);
コード例 #4
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool InvalidateRect(int hWnd, ref RECT lpRect, bool bErase);
コード例 #5
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern int DrawText(IntPtr hDC, string lpString, int nCount, ref RECT lpRect, uint uFormat);
コード例 #6
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool IsRectEmpty(ref RECT lprc);
コード例 #7
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool OffsetRect(ref RECT lprc, int dx, int dy);
コード例 #8
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool CopyRect(string lprcDst, ref RECT lprcSrc);
コード例 #9
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern IntPtr GetDCEx(IntPtr hWnd, RECT hrgnClip, int flags);
コード例 #10
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern int FillRect(IntPtr hDC, ref RECT lprc, IntPtr hbr);
コード例 #11
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern int TileWindows(IntPtr hwndParent, uint wHow, ref RECT lpRect, uint cKids, IntPtr lpKids);
コード例 #12
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool GetClipCursor(ref RECT lpRect);
コード例 #13
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool AdjustWindowRectEx(RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
コード例 #14
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool AdjustWindowRect(ref RECT lpRect, int dwStyle, bool bMenu);
コード例 #15
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool GetClientRect(IntPtr hWnd, ref RECT lpRect);
コード例 #16
0
ファイル: WindowsAPI.cs プロジェクト: xxy1991/cozy
 public static extern bool GetWindowRect(IntPtr handle, ref RECT lpRect);