Exemplo n.º 1
0
        private void StopFlashing()
        {
            _flashTimer.Stop();

            if (_flashingForm != null)
            {
                var info = new NativeMethods.FLASHWINFO();

                info.cbSize  = (uint)Marshal.SizeOf(info);
                info.hWnd    = _flashingForm.Handle;
                info.dwFlags = NativeMethods.FLASHW_STOP;

                NativeMethods.FlashWindowEx(ref info);

                if (_flashingForm.ContainsFocus)
                {
                    NativeMethods.SetWindowPos(
                        _flashingForm.Handle,
                        IntPtr.Zero,
                        0, 0, 0, 0,
                        NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOMOVE |
                        NativeMethods.SWP_NOZORDER | NativeMethods.SWP_FRAMECHANGED
                        );
                }

                _flashingForm = null;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Make the window flash and flicker to get user's attention
 /// </summary>
 /// <param name="Window"></param>
 /// <param name="Count"></param>
 /// <param name="Timeout"></param>
 /// <returns>Window state (active or inactive)</returns>
 public static bool FlashWindow(System.Windows.Forms.Form Window, int Count, int Timeout)
 {
     NativeMethods.FLASHWINFO info = new NativeMethods.FLASHWINFO {
         cbSize    = Marshal.SizeOf(typeof(NativeMethods.FLASHWINFO)),
         hwnd      = Window.Handle,
         uCount    = Count,
         dwTimeout = Timeout
     };
     return(NativeMethods.FlashWindowEx(ref info));
 }
Exemplo n.º 3
0
 public static void Flash(this Window window, int count)
 {
     // ウィンドウを点滅させる
     NativeMethods.FLASHWINFO fwi = new NativeMethods.FLASHWINFO
     {
         hWnd = new WindowInteropHelper(window).Handle,
         dwFlags = 3,
         uCount = count,
         dwTimeout = 0,
     };
     NativeMethods.FlashWindowEx(fwi);
 }
Exemplo n.º 4
0
        void _client_MouseClick(object sender, MouseEventArgs e)
        {
            var handle = NativeMethods.ChildWindowFromPoint(_client.Handle, e.Location);

            if (handle == IntPtr.Zero || handle == _client.Handle)
            {
                return;
            }

            // Find the child that was clicked.

            System.Windows.Forms.Form clickedForm = null;

            foreach (var form in Parent.MdiChildren)
            {
                if (form.Handle == handle)
                {
                    clickedForm = form;
                    break;
                }
            }

            if (clickedForm == null)
            {
                return;
            }

            // Activate the correct form.

            var topForm = FindTopForm(clickedForm);

            if (topForm.ContainsFocus)
            {
                StopFlashing();

                var info = new NativeMethods.FLASHWINFO();

                info.cbSize  = (uint)Marshal.SizeOf(info);
                info.hWnd    = topForm.Handle;
                info.dwFlags = NativeMethods.FLASHW_TIMER | NativeMethods.FLASHW_ALL;

                NativeMethods.FlashWindowEx(ref info);

                _flashingForm = topForm;

                _flashTimer.Start();
            }
            else
            {
                topForm.Focus();
            }
        }
Exemplo n.º 5
0
        public static void Flash(this Window window, int count)
        {
            // ウィンドウを点滅させる
            var fwi = new NativeMethods.FLASHWINFO
            {
                hWnd      = new WindowInteropHelper(window).Handle,
                dwFlags   = 3,
                uCount    = count,
                dwTimeout = 0,
            };

            NativeMethods.FlashWindowEx(fwi);
        }
Exemplo n.º 6
0
 public static void Flash(this Window window, uint count)
 {
     // ウィンドウを点滅させる
     NativeMethods.FLASHWINFO fwi = new NativeMethods.FLASHWINFO
     {
         hwnd = new WindowInteropHelper(window).Handle,
         dwFlags = NativeMethods.FlashWindowFlags.FLASHW_ALL,
         uCount = count,
         dwTimeout = 0,
         cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(NativeMethods.FLASHWINFO)),
     };
     NativeMethods.FlashWindowEx(ref fwi);
 }
Exemplo n.º 7
0
        public bool Notify()
        {
            var fInfo = new NativeMethods.FLASHWINFO
            {
                cbSize    = Convert.ToUInt32(Marshal.SizeOf(typeof(NativeMethods.FLASHWINFO))),
                hwnd      = mainWindow.Handle,
                dwFlags   = NativeMethods.FLASHW_TRAY | NativeMethods.FLASHW_TIMERNOFG,
                uCount    = 2,
                dwTimeout = 0
            };

            return(!NativeMethods.FlashWindowEx(ref fInfo));
        }
        public bool Notify()
        {
            var fInfo = new NativeMethods.FLASHWINFO
            {
                cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(NativeMethods.FLASHWINFO))),
                hwnd = mainWindow.Handle,
                dwFlags = NativeMethods.FLASHW_TRAY | NativeMethods.FLASHW_TIMERNOFG,
                uCount = 2,
                dwTimeout = 0
            };

            return !NativeMethods.FlashWindowEx(ref fInfo);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Flash the current form.
        /// </summary>
        /// <returns>Whether the form need flash or not.</returns>
        private bool FlashForm()
        {
            var info = new NativeMethods.FLASHWINFO();

            info.cbSize = Convert.ToUInt32(Marshal.SizeOf(info));
            this.InvokeIfRequired(() =>
                                  info.hwnd = this.Handle);
            info.dwFlags = NativeMethods.FlashWindowFlags.FLASHW_ALL |
                           NativeMethods.FlashWindowFlags.FLASHW_TIMERNOFG;
            // Flash 3 times
            info.uCount    = 3;
            info.dwTimeout = 0;
            return(NativeMethods.FlashWindowEx(ref info));
        }
Exemplo n.º 10
0
        public static void FlashWindow(IntPtr hwnd, UInt32 count)
        {
            // if the current foreground window isn't this window,
            // flash this window in task bar once every 1 second
            if (NativeMethods.GetForegroundWindow() != hwnd)
            {
                var fInfo = new NativeMethods.FLASHWINFO();

                fInfo.cbSize    = Convert.ToUInt32(Marshal.SizeOf(fInfo));
                fInfo.hwnd      = hwnd;
                fInfo.dwFlags   = NativeMethods.FLASHW_ALL | ((count == 0) ? NativeMethods.FLASHW_TIMERNOFG : 0);
                fInfo.uCount    = count;
                fInfo.dwTimeout = 0;

                NativeMethods.FlashWindowEx(ref fInfo);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Flash a window to indicate a need of attention
        /// </summary>
        public static bool FlashWindowEx(Form form)
        {
            var hWnd  = form.Handle;
            var fInfo = new NativeMethods.FLASHWINFO();

            fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
            fInfo.hwnd   = hWnd;
            if (!form.Focused)
            {
                fInfo.dwFlags   = NativeMethods.FLASHW_ALL | NativeMethods.FLASHW_TIMERNOFG;
                fInfo.uCount    = uint.MaxValue;
                fInfo.dwTimeout = 0;
            }
            else
            {
                fInfo.dwFlags   = NativeMethods.FLASHW_ALL | NativeMethods.FLASHW_TIMER;
                fInfo.uCount    = 3;
                fInfo.dwTimeout = 0;
            }

            return(NativeMethods.FlashWindowEx(ref fInfo));
        }
Exemplo n.º 12
0
        public static void FlashWindow(IntPtr hwnd, UInt32 count)
        {
            // if the current foreground window isn't this window,
            // flash this window in task bar once every 1 second
            if (NativeMethods.GetForegroundWindow() != hwnd)
            {
                var fInfo = new NativeMethods.FLASHWINFO();

                fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
                fInfo.hwnd = hwnd;
                fInfo.dwFlags = NativeMethods.FLASHW_ALL | ((count == 0) ? NativeMethods.FLASHW_TIMERNOFG : 0);
                fInfo.uCount = count;
                fInfo.dwTimeout = 0;

                NativeMethods.FlashWindowEx(ref fInfo);
            }
        }