Esempio n. 1
0
        public static void ResizeWindow(IntPtr hWnd, int width, int height)
        {
            const uint flags = Win32Consts.SWP_FRAMECHANGED | Win32Consts.SWP_NOMOVE |
                               Win32Consts.SWP_NOZORDER | Win32Consts.SWP_NOOWNERZORDER;

            Win32Funcs.SetWindowPosWrapper(hWnd, IntPtr.Zero, 0, 0, width, height, flags);
        }
Esempio n. 2
0
        /// <summary>
        /// 永久将窗口置底
        /// </summary>
        /// <param name="hWnd">窗口句柄</param>
        public static bool SetWindowBottomForever(IntPtr hWnd)
        {
            //SWP_NOSIZE:维持当前尺寸(忽略cx和cy参数)
            //SWP_NOMOVE:维持当前位置(忽略X和Y参数)
            const uint flags = Win32Consts.SWP_NOSIZE | Win32Consts.SWP_NOMOVE | Win32Consts.SE_SHUTDOWN_PRIVILEGE;

            return(Win32Funcs.SetWindowPosWrapper(hWnd, Win32Consts.HWND_BOTTOM_PTR, 0, 0, 0, 0, (int)flags));
        }
Esempio n. 3
0
        /// <summary>
        /// 将窗口置顶
        /// </summary>
        /// <param name="hWnd">窗口句柄</param>
        public static void SetWindowTopMost(IntPtr hWnd)
        {
            //SWP_NOSIZE:维持当前尺寸(忽略cx和cy参数)
            //SWP_NOMOVE:维持当前位置(忽略X和Y参数)
            const uint flags = Win32Consts.SWP_NOSIZE | Win32Consts.SWP_NOMOVE;

            Win32Funcs.SetWindowPosWrapper(hWnd, Win32Consts.HWND_TOPMOST_PTR, 0, 0, 0, 0, flags);
            Win32Funcs.SendMessageWrapper(hWnd, Win32Consts.WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero);

            Win32Funcs.SetForegroundWindowWrapper(hWnd);
        }
Esempio n. 4
0
        /// <summary>
        /// 将窗口移出屏幕可见区域
        /// </summary>
        /// <param name="hWnd">窗口句柄</param>
        public static void SetWindowOutOfScreen(IntPtr hWnd)
        {
            //0, 1040, 147, 858
            Win32Types.Rect winRect;
            Win32Funcs.GetWindowRectWrapper(hWnd, out winRect);

            //0, 1024, 0, 672,ClientToScreen之后坐标为8,178
            Win32Types.Rect clientRect;
            Win32Funcs.GetClientRectWrapper(hWnd, out clientRect);

            var offset = winRect.Width - clientRect.Width;
            var x      = -winRect.Width + offset + 1;
            var y      = winRect.Top;

            const uint flags = Win32Consts.SWP_NOZORDER;

            Win32Funcs.SetWindowPosWrapper(hWnd, IntPtr.Zero, x, y, winRect.Width, winRect.Height, flags);
        }