GetWindowInfo() приватный Метод

private GetWindowInfo ( IntPtr hWnd, WindowInfo &pwi ) : IntPtr
hWnd System.IntPtr
pwi WindowInfo
Результат System.IntPtr
Пример #1
0
        static void PlaceWindowOnScreen(IntPtr hWnd)
        {
            if (IsZoomed(hWnd))
            {
                return;
            }

            WindowInfo wi = Utils.GetWindowInfo(hWnd);

            int maxVisibleArea = 0;

            Rectangle resultWindowRect = new Rectangle();

            bool found = false;

            foreach (var s in Screen.AllScreens)
            {
                int visibleArea = GetWindowVisibleArea(wi, s);

                if (visibleArea > maxVisibleArea)
                {
                    maxVisibleArea = visibleArea;

                    resultWindowRect = GetVisibleRectangle(wi, s);

                    found = true;
                }
            }

            if (found)
            {
                MoveWindow(hWnd, resultWindowRect.X, resultWindowRect.Y, resultWindowRect.Width, resultWindowRect.Height, true);
            }
        }
Пример #2
0
        static WindowInfo GetWindowInfo(IntPtr hwnd, string processName)
        {
            WindowInfo wi = Utils.GetWindowInfo(hwnd);

            string childWindowName = GetChildWindowName(processName);

            if (!String.IsNullOrEmpty(childWindowName))
            {
                EnumChildWindows(hwnd, (IntPtr childHWnd, IntPtr param) => {
                    if (Utils.GetClassName(childHWnd) != childWindowName)
                    {
                        return(true);
                    }

                    wi.rcClient = Utils.GetWindowRect(childHWnd);
                    return(false);
                });
            }

            if (wi.rcWindow.left < 0 && wi.rcWindow.right < 0 && wi.rcWindow.top < 0 && wi.rcWindow.bottom < 0)
            {
                Console.Error.Write("Window is not on the screen");
                Environment.Exit(1);
            }

            return(wi);
        }
Пример #3
0
        static void ResizeWindow(IntPtr hWnd, int width, int height)
        {
            WindowInfo wi = Utils.GetWindowInfo(hWnd);

            SetWindowPos(
                hWnd,
                IntPtr.Zero,
                wi.rcWindow.left,
                wi.rcWindow.top,
                width,
                height,
                SWP_NOCOPYBITS | SWP_NOSENDCHANGING | SWP_SHOWWINDOW | SWP_NOACTIVATE
                );
        }
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.Write("Incorrect arguments");
                Environment.Exit(1);
            }

            IntPtr hwnd = (IntPtr)Convert.ToInt32(args[0]);

            WindowInfo wi = Utils.GetWindowInfo(hwnd);

            Console.Out.WriteLine(wi.rcWindow.right - wi.rcWindow.left);
            Console.Out.WriteLine(wi.rcWindow.bottom - wi.rcWindow.top);
        }