Click here to Skip to main content
15,885,941 members
Articles / Programming Languages / C++

Easy Animated Tray Icon

Rate me:
Please Sign up or sign in to vote.
4.64/5 (12 votes)
4 Feb 20023 min read 214.5K   5.8K   69  
This is a class (SS_TrayIcon) that allows for the easy addition of a tray icon into any project (whether you use MFC or not).
// ----------------------------------------------------------------------- //
//
//  FILENAME:	SS_Wnd.h
//  AUTHOR:		Steve Schaneville
//  CREATED:	22 Jan 2002, 11:26
//
//  PURPOSE:	
//
//  Copyright (c) 2002
//
// ----------------------------------------------------------------------- //
#ifndef __SS_Wnd_h__
#define __SS_Wnd_h__

// ------------------[       Pre-Include Defines       ]------------------ //
// ------------------[          Include Files          ]------------------ //
#include <windows.h>
#include <TCHAR.h>

// ------------------[          Macros/Defines         ]------------------ //
#define SSWND_REGISTERED_NAME (_T("SS_Wnd"))

// ------------------[      Constants/Enumerations     ]------------------ //
// ------------------[       Forward Declarations      ]------------------ //
// ------------------[         Global Variables        ]------------------ //
// ------------------[         Global Functions        ]------------------ //
// ------------------[             Classes             ]------------------ //

// ----------------------------------------------------------------------- //
//  Class:			SS_Wnd
//  Author:			Steve Schaneville
//  Notes:			
// ----------------------------------------------------------------------- //
class SS_Wnd
{
public:

    DECLARE_DYNAMIC(SS_Wnd);
        
    // construction, destruction, assignment, copy, initialization
	SS_Wnd                                          (HINSTANCE hInstance);
	virtual ~SS_Wnd                                 ();

	SS_Wnd					    		            (SS_Wnd& rhs);
	SS_Wnd&			        operator =		        (SS_Wnd& rhs);

protected:

    virtual VOID	        InitObject		        ();

public:

	// accessor functions
    VOID                    Instance                (HINSTANCE hInstance);
    const HINSTANCE         Instance                () const;
    VOID                    WindowHandle            (HWND hWnd);
    const HWND              WindowHandle            () const;

    // utilities
    VOID                    Create                  ();
    virtual LRESULT         WindowProc              (UINT message, 
                                                     WPARAM wParam, 
                                                     LPARAM lParam);
    virtual VOID            OnTimer                 (UINT uMsg,
                                                     UINT_PTR idEvent,
                                                     DWORD dwTime);
    virtual UINT_PTR        SetTimer                (UINT nIDEvent, 
                                                     UINT uElapse,
                                                     TIMERPROC lpTimerProc=NULL);
    virtual BOOL            KillTimer               (UINT nIDEvent);
    
protected:


    
private:

    VOID                    RegisterClass           ();

    static BOOL     m_bClassIsRegistered;
    HINSTANCE       m_hInstance;
    HWND            m_hWnd;

};


// ----------------------------------------------------------------------- //
//  SS_Wnd Inline Functions
// ----------------------------------------------------------------------- //

inline VOID SS_Wnd::Instance(HINSTANCE hInstance)
{ m_hInstance = hInstance; }

inline const HINSTANCE SS_Wnd::Instance() const
{ return m_hInstance; }

inline VOID SS_Wnd::WindowHandle(HWND hWnd)
{ m_hWnd = hWnd; }

inline const HWND SS_Wnd::WindowHandle() const
{ return m_hWnd; }


#endif // __SS_Wnd_h__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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


Written By
Architect Amedisys
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions