Looking to notify your users when an application wants its needs met? A sure fire way is to have its taskbar icon flash. Here’s how.
First, import those namespaces, people:
using System.Windows.Interop; using System.Runtime.InteropServices;
Next, declare the Windows API FlashWindow method.
[DllImport("user32")] public static extern int FlashWindow(IntPtr hwnd, bool bInvert);
Notice the first parameter is a IntPtr, NOT an int, like I found at one of the websites I visited trying to get this working. An int will get you nowhere. IntPtr is your friend.
Now create a WindowInteropHelper by passing the WPF Window object that you are calling the code from. Pass the window’s Handle property to the FlashWindow method, along with a value of “true”, to tell it that you want the awesome flashing taskbar effect.
WindowInteropHelper wih = new WindowInteropHelper(ThisWindow); FlashWindow(wih.Handle, true);
There we go, a simple way to alert users when your application is done or has updated information.