Click here to Skip to main content
15,886,836 members
Articles / Programming Languages / C++

CTrayIcon - System Tray Icon Wrapper

Rate me:
Please Sign up or sign in to vote.
3.17/5 (14 votes)
6 Jun 20078 min read 175.3K   5K   47  
An article exhibiting a wrapper class for System Taskbar icon.
// MouseMsgHandlerImpl.h : header file

#pragma once

#include "TrayIcon.h"
#include "TrayIconMouseMsgHandler.h"
#include "Utilities.h"

// Left mouse button double click message handler
class CLeftMouseDblClickMsgHandler: public CTrayIconMouseMsgHandler
{
public:

	CLeftMouseDblClickMsgHandler() : CTrayIconMouseMsgHandler(WM_LBUTTONDBLCLK){}

	void MouseMsgHandler()
	{
		ShowWnd(AfxGetMainWnd());
	}
};

// Right mouse button click message handler
class CRightMouseClickMsgHandler: public CTrayIconMouseMsgHandler
{
public:

	CRightMouseClickMsgHandler() : CTrayIconMouseMsgHandler(WM_RBUTTONDOWN){}

	void MouseMsgHandler()
	{
		ShowPopupMenu(AfxGetMainWnd(), IDR_TASKBAR_MENU, 0);
	}
};

// Mouse hover message handler
class CMouseHoverMsgHandler: public CTrayIconMouseMsgHandler
{
public:

	CMouseHoverMsgHandler(CTrayIcon* pTrayIcon) : CTrayIconMouseMsgHandler(WM_MOUSEFIRST)
	{
		m_pTrayIcon = pTrayIcon;
	}

	void SetTrayIcon(CTrayIcon* pTrayIcon)
	{
		m_pTrayIcon = pTrayIcon;
	}

	void MouseMsgHandler()
	{
		m_pTrayIcon->HoverIcon();
	}

private:

	CTrayIcon* m_pTrayIcon;
};

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
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions