How to Flash a Window icon in the taskbar

28 01 2012

You must have noticed that in the chat applications like MSN messenger or Google Talk, when we get a message and our chat window is minimized at that instant, it will start blinking on the task bar. That means in any occasion where the application has to notify the user that  it needs their attention to minimized window in the task bar.

Windows applications provide APIs FlashWindow and FlashWindowEx to flashes the specified window.

Before using this function we have to create a FLASHWINFO structure and fill it with flash status of the window and number of times the system has to flash the window.

 

//CDialog derived class
CMyDialog* m_pMyDlg;
FLASHWINFO info;
void CreateFlashWindow()
{
//Create a window
m_pMyDlg = new CMyDialog();
m_pMyDlg->Create(IDD_MYDIALOG);

//Show window
m_pMyDlg->ShowWindow(SW_MINIMIZE);

//Fill blinking info
if (m_pMyDlg->m_hWnd)
{
info.cbSize = sizeof(info);
info.hwnd = m_pMyDlg->m_hWnd;
info.dwFlags = FLASHW_ALL;
info.dwTimeout = 0;
info.uCount = 3;
}
}

//any time the minimized application window
//need to get user attention, call this method
void OnNotifyUser()
{
::FlashWindowEx(&info);
}

If you just want to flash the window once, use FlashWindow function. To flash the window a specified number of times, use FlashWindowEx functions.

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: