BrowserTools.Utils.ForceForegroundWindow C# (CSharp) Метод

ForceForegroundWindow() публичный статический Метод

public static ForceForegroundWindow ( IntPtr hWnd ) : void
hWnd System.IntPtr
Результат void
        public static void ForceForegroundWindow(IntPtr hWnd)
        {
            SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
            SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
            SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

            System.Threading.Thread.Sleep(FOREGROUNDING_WINDOW_DELAY);
        }

Usage Example

Пример #1
0
        static Bitmap CaptureFromScreen(IntPtr hwnd, WindowInfo wi)
        {
            using (var guard = new ForegroundWindowGuard()) {
                if (guard.ForegroundWindow != hwnd)
                {
                    Utils.ForceForegroundWindow(hwnd);
                }

                Bitmap windowBitmap = new Bitmap(
                    wi.rcWindow.right - wi.rcWindow.left,
                    wi.rcWindow.bottom - wi.rcWindow.top,
                    System.Drawing.Imaging.PixelFormat.Format32bppRgb
                    );

                Graphics graphicsWindow = Graphics.FromImage(windowBitmap);

                graphicsWindow.CopyFromScreen(
                    new Point(wi.rcWindow.left, wi.rcWindow.top),
                    Point.Empty,
                    windowBitmap.Size,
                    CopyPixelOperation.SourceCopy
                    );

                return(windowBitmap);
            }
        }
All Usage Examples Of BrowserTools.Utils::ForceForegroundWindow