コード例 #1
0
ファイル: PlatformApi.cs プロジェクト: barrycodes/scrape-ps
        public static WindowInfo GetWindowInfo(IntPtr hwnd)
        {
            WindowInfo result = null;

            Platform.WindowInfo windowInfo = new Platform.WindowInfo();

            Platform.User32.GetWindowInfo(hwnd, ref windowInfo);
            Rectangle bounds = windowInfo.rcWindow.ToRectangle();

            string title = GetWindowText(hwnd);

            bool isVisible = Platform.User32.IsWindowVisible(hwnd);

            WindowPlacement placement = WindowPlacement.Default;
            User32.GetWindowPlacement(hwnd, ref placement);
            ShowWindowCommands windowCommands = placement.ShowCmd;
            Rectangle normalBounds = placement.NormalPosition.ToRectangle();
            int zOrder = GetZOrder(hwnd);

            //result = new WindowInfo(hwnd, title, isVisible, bounds);
            result =
                new WindowInfo {
                    Handle=hwnd,
                    Title=title,
                    Visible=isVisible,
                    Bounds=bounds,
                    State=windowCommands,
                    NormalBounds=normalBounds,
                    MinimizedPosition=placement.MinPosition.ToPoint(),
                    MaximizedPosition=placement.MaxPosition.ToPoint(),
                    PlacementFlags=placement.Flags,
                    ZOrder=zOrder,
                };

            return result;
        }
コード例 #2
0
 public static extern bool GetWindowInfo(IntPtr hwnd, ref WindowInfo pwi);