-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ntray.h
136 lines (104 loc) · 7.68 KB
/
Ntray.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//////////////////////////////////////////////////
//类名:CTrayNotifyIcon
//功能:系统区动态图标显示效果
//修改人:徐景周(Johnny Xu, xujingzhou2016@gmail.com)
//组织:未来工作室(Future Studio)
//日期:2001.12.1
//////////////////////////////////////////////////
////////////////////////////////// Macros ///////////////////////////
#ifndef _NTRAY_H__
#define _NTRAY_H__
/////////////////////////// Classes /////////////////////////////////
//forward declaration
class CTrayNotifyIcon;
//internal class used to handle IE4 taskbar creation notification message
class CTrayRessurectionWnd : public CFrameWnd
{
public:
//Constructors / Destructors
CTrayRessurectionWnd(CTrayNotifyIcon* pTrayIcon);
protected:
CTrayNotifyIcon* m_pTrayIcon;
//{{AFX_MSG(CTrayRessurectionWnd)
//}}AFX_MSG
afx_msg LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CTrayRessurectionWnd)
};
//internal class used to implement animated tray icons
class CTrayTimerWnd : public CFrameWnd
{
public:
//Constructors / Destructors
CTrayTimerWnd(CTrayNotifyIcon* pTrayIcon, HICON* phIcons, int nNumIcons, DWORD dwDelay);
~CTrayTimerWnd();
//retreive the current icon
HICON GetCurrentIcon() const { return m_phIcons[m_nCurrentIconIndex]; };
protected:
CTrayNotifyIcon* m_pTrayIcon;
HICON* m_phIcons;
int m_nNumIcons;
DWORD m_dwDelay;
UINT m_nTimerID;
int m_nCurrentIconIndex;
//{{AFX_MSG(CTrayTimerWnd)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
afx_msg LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CTrayTimerWnd)
};
//the actual tray notification class wrapper
class CTrayNotifyIcon : public CObject
{
public:
//Constructors / Destructors
CTrayNotifyIcon();
~CTrayNotifyIcon();
//Create the tray icon
BOOL Create(CWnd* pNotifyWnd, UINT uID, LPCTSTR pszTooltipText, HICON hIcon, UINT nNotifyMessage);
BOOL Create(CWnd* pNotifyWnd, UINT uID, LPCTSTR pszTooltipText, HICON* phIcons, int nNumIcons, DWORD dwDelay, UINT nNotifyMessage);
//Change or retrieve the Tooltip text
BOOL SetTooltipText(LPCTSTR pszTooltipText);
BOOL SetTooltipText(UINT nID);
CString GetTooltipText() const;
//Change or retrieve the icon displayed
BOOL SetIcon(HICON hIcon);
BOOL SetIcon(LPCTSTR lpIconName);
BOOL SetIcon(UINT nIDResource);
BOOL SetIcon(HICON* phIcons, int nNumIcons, DWORD dwDelay);
BOOL SetStandardIcon(LPCTSTR lpIconName);
BOOL SetStandardIcon(UINT nIDResource);
HICON GetIcon() const;
BOOL UsingAnimatedIcon() const { return m_bAnimated; };
//Change or retrieve the window to send notification messages to
BOOL SetNotificationWnd(CWnd* pNotifyWnd);
CWnd* GetNotificationWnd() const;
//Modification of the tray icons
void HideIcon();
void ShowIcon();
void RemoveIcon();
void MoveToExtremeRight();
//Default handler for tray notification message
virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent);
//Status information
BOOL IsShowing() const { return !IsHidden(); };
BOOL IsHidden() const { return m_bHidden; };
protected:
BOOL CreateTimerWindow(HICON* phIcons, int nNumIcons, DWORD dwDelay);
void DestroyTimerWindow();
BOOL CreateRessurectionWindow();
void DestroyResurrectionWindow();
NOTIFYICONDATA m_NotifyIconData;
BOOL m_bCreated;
BOOL m_bHidden;
CWnd* m_pNotificationWnd;
CTrayTimerWnd* m_pTimerWnd;
CTrayRessurectionWnd* m_pResurrectionWnd;
BOOL m_bAnimated;
DECLARE_DYNAMIC(CTrayNotifyIcon)
friend class CTrayTimerWnd;
};
#endif //_NTRAY_H__