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

How to implement mouse hover/leave message on system tray.

Rate me:
Please Sign up or sign in to vote.
3.36/5 (9 votes)
23 Aug 20042 min read 86.4K   1.6K   23  
Ever wanted to get mouse hover/leave message from system tray? Windows shell doesn't support that. This class is a solution that works.
// TrayPosDemoDlg.h : header file
//

#if !defined(AFX_TRAYPOSDEMODLG_H__D2FD3DCD_5FF9_4B00_B226_27BF9C888FE4__INCLUDED_)
#define AFX_TRAYPOSDEMODLG_H__D2FD3DCD_5FF9_4B00_B226_27BF9C888FE4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CTrayPosDemoDlg dialog

#include "traypos.h"
#include "bmpdlg.h"

#define WM_TRAYNOTIFY (WM_USER+123)

class CTrayPosDemoDlg : public CDialog
{
// Construction
public:
	CTrayPosDemoDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CTrayPosDemoDlg)
	enum { IDD = IDD_TRAYPOSDEMO_DIALOG };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTrayPosDemoDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

private:
	CMsgTrayPos	m_traypos;
	CBmpDlg		m_dlg;


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CTrayPosDemoDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnDestroy();
	//}}AFX_MSG
	afx_msg LONG OnTrayNotify(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TRAYPOSDEMODLG_H__D2FD3DCD_5FF9_4B00_B226_27BF9C888FE4__INCLUDED_)

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
Chief Technology Officer Wellbia.com Co., Ltd.
Korea (Republic of) Korea (Republic of)
YoungJin is a co-founder of Wellbia.com Co., Ltd., a security company in South Korea, and Visual C++ Microsoft Most Valuable Professional. He has developed anti-cheat program called XIGNCODE since 2007. He wrote several PC security programs like PC Firewall, Anti-Spyware, and Keyboard Security Software. He has contributed a number of articles about Windows programming to Microsoftware, the famous programming magazine of South Korea. He also hosts a blog (http://www.jiniya.net) that includes articles about system programming on Windows.

Comments and Discussions