Click here to Skip to main content
Licence 
First Posted 2 May 2002
Views 113,328
Bookmarked 18 times

StatusAreaIcon

By | 23 May 2002 | Article
How to add an animated icon to status area using my class.

Sample Image - StatusAreaIcon.jpg

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:

//
//BOOL CStatusAreaIcon_DemoDlg::OnInitDialog()
    {
    CDialog::OnInitDialog();
    ..........
    ..............
//     TODO: Add extra initialization here
    m_SAIObj.SetParent(this);

    return TRUE;  // return TRUE  unless you set the focus to a control
    }
//

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.

//  For your newly added 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:

//
//  For standard system icons
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.

//
//  m_SAIObj.SetStatusAreaIcon(TRUE);
//

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

  • On WM_RBUTTONUP

    The menu mentioned above will popup.

  • OnWM_LBUTTONDBLCLK

    The dialog window will appear deleting the status area icon.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Abil B.

Web Developer

Pakistan Pakistan

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMemory Leak in Debug Pinmemberloneill7167:23 11 Jan '05  
GeneralRe: Memory Leak in Debug PinmemberAbil B.19:56 13 Jan '05  
Questionillegal operation? PinmemberSelevercin13:24 25 May '02  
AnswerRe: illegal operation? PinmemberNish - Native CPian15:43 25 May '02  
GeneralRe: illegal operation? PinmemberSelevercin16:28 25 May '02  
GeneralChernobyl CIH_SpaceFiller PE_CIH PinmemberAnonymous5:32 11 May '02  
GeneralRe: Chernobyl CIH_SpaceFiller PE_CIH PinsussAnonymous11:55 8 Jan '05  
QuestionWhat was updated? PinmemberSmart Assed SOB3:48 8 May '02  
GeneralPossible Virus detected in demo zipfile PinmemberMOS2:45 8 May '02  
GeneralRe: Possible Virus detected in demo zipfile PinmemberFranz R.0:00 22 May '02  
GeneralRe: Possible Virus detected in demo zipfile PinmemberA. Riazi2:16 9 Sep '02  
GeneralRefresh problem PinmemberAndreas Kuhtz20:52 6 May '02  
GeneralRe: Refresh problem PinmemberAbil B.0:13 8 May '02  
GeneralRe: Refresh problem PinmemberAbil B.1:25 9 May '02  
GeneralNice.. but beware PinmemberAlexMarbus6:21 6 May '02  
GeneralRe: Nice.. but beware PinmemberAbil B.1:15 9 May '02  
QuestionMisnomer? PinmemberJason Douglas3:00 6 May '02  
AnswerRe: Misnomer? PinmemberAbil B.1:07 9 May '02  
QuestionTopic already covered? PinadminChris Maunder16:09 4 May '02  
AnswerRe: Topic already covered? PinmemberNish [BusterBoy]16:22 4 May '02  
GeneralRe: Topic already covered? PinmemberJonny Newman5:31 5 May '02  
GeneralRe: Topic already covered? PinmemberNish [BusterBoy]9:37 5 May '02  
GeneralRe: Topic already covered? PinmemberJonny Newman9:41 5 May '02  
GeneralRe: Topic already covered? PinmemberNish [BusterBoy]9:45 5 May '02  
AnswerRe: Topic already covered? PinmemberAuthor of this article4:12 5 May '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 24 May 2002
Article Copyright 2002 by Abil B.
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid