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; } }
/// <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)); }
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); }
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(); } }
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); }
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); }
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); }
/// <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)); }
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); } }
/// <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)); }