예제 #1
0
        private WindowSnap(IntPtr hWnd, bool specialCapturing)
        {
            this.isIconic = WindowSnap.IsIconic(hWnd);
            this.hWnd     = hWnd;
            if (specialCapturing)
            {
                WindowSnap.EnterSpecialCapturing(hWnd);
            }
            WindowSnap.WINDOWINFO wINDOWINFO = new WindowSnap.WINDOWINFO()
            {
                cbSize = WindowSnap.WINDOWINFO.GetSize()
            };
            WindowSnap.GetWindowInfo(hWnd, ref wINDOWINFO);
            bool      flag            = false;
            IntPtr    parent          = WindowSnap.GetParent(hWnd);
            Rectangle windowPlacement = new Rectangle();
            Rectangle rectangle       = new Rectangle();

            if (WindowSnap.forceMDI && parent != IntPtr.Zero && (wINDOWINFO.dwExStyle & WindowSnap.ExtendedWindowStyles.WS_EX_MDICHILD) == WindowSnap.ExtendedWindowStyles.WS_EX_MDICHILD)
            {
                StringBuilder stringBuilder = new StringBuilder();
                WindowSnap.GetClassName(parent, stringBuilder, "RunDLL".Length + 1);
                if (stringBuilder.ToString() != "RunDLL")
                {
                    flag            = true;
                    windowPlacement = WindowSnap.GetWindowPlacement(hWnd);
                    WindowSnap.MoveWindow(hWnd, 2147483647, 2147483647, windowPlacement.Width, windowPlacement.Height, true);
                    WindowSnap.SetParent(hWnd, IntPtr.Zero);
                    rectangle = WindowSnap.GetWindowPlacement(parent);
                }
            }
            Rectangle windowPlacement1 = WindowSnap.GetWindowPlacement(hWnd);

            this.size     = windowPlacement1.Size;
            this.location = windowPlacement1.Location;
            this.text     = WindowSnap.GetWindowText(hWnd);
            this.image    = WindowSnap.GetWindowImage(hWnd, this.size);
            if (flag)
            {
                WindowSnap.SetParent(hWnd, parent);
                int left = wINDOWINFO.rcWindow.Left - rectangle.X;
                int top  = wINDOWINFO.rcWindow.Top - rectangle.Y;
                if ((wINDOWINFO.dwStyle & WindowSnap.WindowStyles.WS_THICKFRAME) == WindowSnap.WindowStyles.WS_THICKFRAME)
                {
                    left -= 100; //SystemInformation.Border3DSize.Width;

                    top -= 100;  //SystemInformation.Border3DSize.Height;
                }
                WindowSnap.MoveWindow(hWnd, left, top, windowPlacement.Width, windowPlacement.Height, true);
            }
            if (specialCapturing)
            {
                WindowSnap.ExitSpecialCapturing(hWnd);
            }
        }
예제 #2
0
 private static extern bool GetWindowInfo(IntPtr hwnd, ref WindowSnap.WINDOWINFO pwi);