Using C Sharp to make application flash at bottom of screen?

B

Bernard.Mangay

At the bottom of a windows screen are those rectangular boxes for each
application. Sometimes they flash to alert the user that somethign has
happened. How can I make my own C Sharp applications flash?
 
L

Luthgers, John

use the following code in your form class .... or change it as needed.

-J-

private void FlashIt()
{
FLASHWINFO fi = new FLASHWINFO();
fi.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(fi);
fi.hwnd = Handle;
fi.dwFlags = FLASHW_TRAY;
fi.uCount = 3;
fi.dwTimeout = 0;
FlashWindowEx(ref fi);
}

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FlashWindowEx(ref FLASHWINFO pwfi);

[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 uCount;
public UInt32 dwTimeout;
}



//Stop flashing. The system restores the window to its original state.
public const UInt32 FLASHW_STOP = 0;
//Flash the window caption.
public const UInt32 FLASHW_CAPTION = 1;
//Flash the taskbar button.
public const UInt32 FLASHW_TRAY = 2;
//Flash both the window caption and taskbar button.
//This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
public const UInt32 FLASHW_ALL = 3;
//Flash continuously, until the FLASHW_STOP flag is set.
public const UInt32 FLASHW_TIMER = 4;
//Flash continuously until the window comes to the foreground.
public const UInt32 FLASHW_TIMERNOFG = 12;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top