Beispiel #1
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                form.BringToFront();
                form.Focus();
                form.Show();
                form.Activate();

                // stop flashing...happens occassionally when switching quickly when activate manuver is fails
                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
Beispiel #2
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                // bring to top
                form.TopMost = true;
                form.TopMost = false;

                // set as active form in task bar
                form.Activate();

                // stop flashing...happens occassionally when switching quickly when activate manuver is fails
                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
Beispiel #3
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                // bring to top
                form.TopMost = true;
                form.TopMost = false;

                // set as active form in task bar
                form.Activate();

                // stop flashing...happens occassionally when switching quickly when activate manuver is fails
                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
Beispiel #4
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                // Send press of Alt key so that the main window can be activated w/o user interaction
                NativeMethods.keybd_event(VK_MENU, 0xb8, 0, 0);
                // Activate main window
                form.Activate();
                // Release Alt key
                NativeMethods.keybd_event(VK_MENU, 0xb8, KEYEVENTF_KEYUP, 0);

                // Set foreground back to terminal window
                //NativeMethods.SetForegroundWindow(hwnd);
            }
        }
Beispiel #5
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                IntPtr Dummy = IntPtr.Zero;

                IntPtr hWnd = form.Handle;
                NativeMethods.ShowWindowAsync(hWnd, NativeMethods.IsIconic(hWnd) ? SW_RESTORE : SW_SHOW);
                NativeMethods.SetForegroundWindow(hWnd);

                // Code from Karl E. Peterson, www.mvps.org/vb/sample.htm
                // Converted to Delphi by Ray Lischner
                // Published in The Delphi Magazine 55, page 16
                // Converted to C# by Kevin Gale
                IntPtr foregroundWindow = NativeMethods.GetForegroundWindow();
                if (foregroundWindow != hWnd)
                {
                    uint foregroundThreadId = NativeMethods.GetWindowThreadProcessId(foregroundWindow, Dummy);
                    uint thisThreadId       = NativeMethods.GetWindowThreadProcessId(hWnd, Dummy);

                    if (NativeMethods.AttachThreadInput(thisThreadId, foregroundThreadId, true))
                    {
                        NativeMethods.BringWindowToTop(hWnd); // IE 5.5 related hack
                        NativeMethods.SetForegroundWindow(hWnd);
                        NativeMethods.AttachThreadInput(thisThreadId, foregroundThreadId, false);
                    }
                }

                if (NativeMethods.GetForegroundWindow() != hWnd)
                {
                    // Code by Daniel P. Stasinski
                    // Converted to C# by Kevin Gale
                    IntPtr Timeout = IntPtr.Zero;
                    NativeMethods.SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Timeout, 0);
                    NativeMethods.SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Dummy, SPIF_SENDCHANGE);
                    NativeMethods.BringWindowToTop(hWnd); // IE 5.5 related hack
                    NativeMethods.SetForegroundWindow(hWnd);
                    NativeMethods.SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Timeout, SPIF_SENDCHANGE);
                }


                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
Beispiel #6
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                IntPtr Dummy = IntPtr.Zero;

                IntPtr hWnd = form.Handle;
                if (NativeMethods.IsIconic(hWnd))
                {
                    NativeMethods.ShowWindowAsync(hWnd, SW_RESTORE);
                }
                else
                {
                    NativeMethods.ShowWindowAsync(hWnd, SW_SHOW);
                }
                NativeMethods.SetForegroundWindow(hWnd);

                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
Beispiel #7
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                // set as active form in task bar
                NativeMethods.ShowWindow(form.Handle, NativeMethods.WindowShowStyle.Restore);
                NativeMethods.SetForegroundWindow(form.Handle);
                Application.DoEvents();

                // stop flashing...happens occassionally when switching quickly when activate manuver is fails
                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
Beispiel #8
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                // Send press of Alt key so that the main window can be activated w/o user interaction
                NativeMethods.keybd_event(VK_MENU, 0xb8, 0, 0);
                // Activate main window
                form.Activate();
                // Release Alt key
                NativeMethods.keybd_event(VK_MENU, 0xb8, KEYEVENTF_KEYUP, 0);

                // Set foreground back to terminal window
                //NativeMethods.SetForegroundWindow(hwnd);
            }

        }
Beispiel #9
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                IntPtr Dummy = IntPtr.Zero;

                IntPtr hWnd = form.Handle;
                NativeMethods.ShowWindowAsync(hWnd, NativeMethods.IsIconic(hWnd) ? SW_RESTORE : SW_SHOW);
                NativeMethods.SetForegroundWindow(hWnd);

                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }

        }
Beispiel #10
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                IntPtr Dummy = IntPtr.Zero;

                IntPtr hWnd = form.Handle;
                NativeMethods.ShowWindowAsync(hWnd, NativeMethods.IsIconic(hWnd) ? SW_RESTORE : SW_SHOW);
                NativeMethods.SetForegroundWindow(hWnd);

                // Code from Karl E. Peterson, www.mvps.org/vb/sample.htm
                // Converted to Delphi by Ray Lischner
                // Published in The Delphi Magazine 55, page 16
                // Converted to C# by Kevin Gale
                IntPtr foregroundWindow = NativeMethods.GetForegroundWindow();
                if (foregroundWindow != hWnd)
                {
                    uint foregroundThreadId = NativeMethods.GetWindowThreadProcessId(foregroundWindow, Dummy);
                    uint thisThreadId = NativeMethods.GetWindowThreadProcessId(hWnd, Dummy);

                    if (NativeMethods.AttachThreadInput(thisThreadId, foregroundThreadId, true))
                    {
                        NativeMethods.BringWindowToTop(hWnd); // IE 5.5 related hack
                        NativeMethods.SetForegroundWindow(hWnd);
                        NativeMethods.AttachThreadInput(thisThreadId, foregroundThreadId, false);
                    }
                }

                if (NativeMethods.GetForegroundWindow() != hWnd)
                {
                    // Code by Daniel P. Stasinski
                    // Converted to C# by Kevin Gale
                    IntPtr Timeout = IntPtr.Zero;
                    NativeMethods.SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Timeout, 0);
                    NativeMethods.SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Dummy, SPIF_SENDCHANGE);
                    NativeMethods.BringWindowToTop(hWnd); // IE 5.5 related hack
                    NativeMethods.SetForegroundWindow(hWnd);
                    NativeMethods.SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Timeout, SPIF_SENDCHANGE);
                }


                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);

            }


        }
Beispiel #11
0
 public abstract void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd);
Beispiel #12
0
        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                uint fgProcessId;
                uint spProcessId;
                NativeMethods.GetWindowThreadProcessId(NativeMethods.GetForegroundWindow(), out fgProcessId);
                NativeMethods.GetWindowThreadProcessId(form.Handle, out spProcessId);

                if (fgProcessId != spProcessId)
                {
                    if (NativeMethods.AttachThreadInput(fgProcessId, spProcessId, true))
                    {
                        NativeMethods.SetForegroundWindow(form.Handle);
                        NativeMethods.AttachThreadInput(fgProcessId, spProcessId, false);
                    }
                }
                else
                {
                    NativeMethods.SetForegroundWindow(form.Handle);
                }

                // stop flashing...happens occassionally when switching quickly when activate manuver is fails
                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
Beispiel #13
0
 public abstract void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd);