
Introduction
This time I am giving you my class which will not only help you to send your application's icon to the status bar but will also make it animated. I have tried my best to make this class as easy to use as possible, and I am sure I got a lot of success in it.
Features:
- Places any icon given by you in the Windows Status Area.
- Allows you to make animated icon in Windows Status Area.
- Allows you to control the speed of animated icon.
How to use this class (CStatusAreaIconObj):
I recommend not to overload any mouse message handler unless you have a deep understanding with this class. Make a member variable of CStatusAreaIconObj class or any inherited class in your Dialog class. In case you have inherited your class from this class or you are using this class in your project, your first step will be to include SetParent(CDialog* pDlg) member function in the OnInitDialog() of your Dialog class passing this pointer as an argument to this function. This is shown here:
{
CDialog::OnInitDialog();
..........
..............
m_SAIObj.SetParent(this);
return TRUE; }
Now, to add a single icon or an animated icon to the status area, all you need is to call InitializeObject() member function of this class. The parameters are:
InitializeObject(LPCTSTR lpIconName, HWND hWnd, CString strTooltip, UINT nSubMenu)
The first parameter is the icon name, second is the m_hWnd variable of your Dialog class. The third parameter is a constant string which will be set as a tooltip for your icon, and the last is the number of submenu which you want to add as a floating popup menu which will appear when a mouse button is clicked on the status area icon.
m_SAIObj.InitializeObject(MAKEINTRESOURCE(IDI_SADFACE), m_hWnd,
"Click on your favourite Face...", 0);
If you want to use a standard system icon then you will directly give its name as:
m_SAIObj.InitializeObject(IDI_ERROR, m_hWnd,
"Click on your favourite Face...", 0);
After this, you have to set the status area icon by calling SetStatusAreaIcon member function. It has a boolean parameter which will be TRUE if you want to hide window after sending the icon to status area, and it will be FALSE if you want to keep your dialog window visible while sending the icon to status area.
If you want to make the icon animated, you will call the following function with at least two icons and a time interval of the animation. In the following example, 1 means 1 second interval.
m_SAIChildObj.SetIconAnimated(1, MAKEINTRESOURCE(IDI_ANGRYFACE),
MAKEINTRESOURCE(IDI_SHADESFACE),
MAKEINTRESOURCE(IDI_TEETHFACE),
MAKEINTRESOURCE(IDI_TOUNGFACE),
MAKEINTRESOURCE(IDI_WINKFACE));
To restore Dialog window, you will have to call RestoreWindow(BOOL bDeleteStatusAreaIcon) function. If parameter is true, the dialog window will be restored and the status area icon will be destroyed, and if the parameter is false the dialog window will be restored and the status area icon will also stay there where it was.
m_SAIObj.RestoreWindow(TRUE);
NOTE:
To destroy Status Area Icon, you will have to call DestroyObject() function.
m_SAIObj.DeleteObject();
That is all you need to do to play with Status Area Icon using my class. Best Of Luck. ;)
Default Message Handlers