3 struct InternalIconData
: NOTIFYICONDATA
5 // Must keep a separate copy since the original is unioned with uTimeout.
13 NOTIFYICONDATA IconData
;
15 IconWatcherData(NOTIFYICONDATA
*iconData
) :
16 hProcess(NULL
), ProcessId(0)
18 IconData
.cbSize
= sizeof(NOTIFYICONDATA
);
19 IconData
.hWnd
= iconData
->hWnd
;
20 IconData
.uID
= iconData
->uID
;
21 IconData
.guidItem
= iconData
->guidItem
;
28 CloseHandle(hProcess
);
35 CAtlList
<IconWatcherData
*> m_WatcherList
;
36 CRITICAL_SECTION m_ListLock
;
37 HANDLE m_hWatcherThread
;
45 virtual ~CIconWatcher();
47 bool Initialize(_In_ HWND hWndParent
);
50 bool AddIconToWatcher(_In_ NOTIFYICONDATA
*iconData
);
51 bool RemoveIconFromWatcher(_In_ NOTIFYICONDATA
*iconData
);
53 IconWatcherData
* GetListEntry(_In_opt_ NOTIFYICONDATA
*iconData
, _In_opt_ HANDLE hProcess
, _In_
bool Remove
);
57 static UINT WINAPI
WatcherThread(_In_opt_ LPVOID lpParam
);
63 static const int TimerInterval
= 2000;
64 static const int BalloonsTimerId
= 1;
65 static const int MinTimeout
= 10000;
66 static const int MaxTimeout
= 30000;
67 static const int CooldownBetweenBalloons
= 2000;
72 InternalIconData
* pSource
;
74 WCHAR szInfoTitle
[64];
78 Info(InternalIconData
* source
)
81 StrNCpy(szInfo
, source
->szInfo
, _countof(szInfo
));
82 StrNCpy(szInfoTitle
, source
->szInfoTitle
, _countof(szInfoTitle
));
83 uIcon
= source
->dwInfoFlags
& NIIF_ICON_MASK
;
84 if (source
->dwInfoFlags
== NIIF_USER
)
85 uIcon
= reinterpret_cast<WPARAM
>(source
->hIcon
);
86 uTimeout
= source
->uTimeout
;
92 CTooltips
* m_tooltips
;
94 CAtlList
<Info
> m_queue
;
96 CToolbar
<InternalIconData
> * m_toolbar
;
98 InternalIconData
* m_current
;
106 void Init(HWND hwndParent
, CToolbar
<InternalIconData
> * toolbar
, CTooltips
* balloons
);
109 bool OnTimer(int timerId
);
110 void UpdateInfo(InternalIconData
* notifyItem
);
111 void RemoveInfo(InternalIconData
* notifyItem
);
116 int IndexOf(InternalIconData
* pdata
);
117 void SetTimer(int length
);
118 void Show(Info
& info
);
119 void Close(IN OUT InternalIconData
* notifyItem
);
122 class CNotifyToolbar
:
123 public CWindowImplBaseT
< CToolbar
<InternalIconData
>, CControlWinTraits
>
125 HIMAGELIST m_ImageList
;
126 int m_VisibleButtonCount
;
128 CBalloonQueue
* m_BalloonQueue
;
132 virtual ~CNotifyToolbar();
134 int GetVisibleButtonCount();
135 int FindItem(IN HWND hWnd
, IN UINT uID
, InternalIconData
** pdata
);
136 int FindExistingSharedIcon(HICON handle
);
137 BOOL
AddButton(IN CONST NOTIFYICONDATA
*iconData
);
138 BOOL
SwitchVersion(IN CONST NOTIFYICONDATA
*iconData
);
139 BOOL
UpdateButton(IN CONST NOTIFYICONDATA
*iconData
);
140 BOOL
RemoveButton(IN CONST NOTIFYICONDATA
*iconData
);
141 VOID
ResizeImagelist();
144 VOID
SendMouseEvent(IN WORD wIndex
, IN UINT uMsg
, IN WPARAM wParam
);
145 LRESULT
OnMouseEvent(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
146 LRESULT
OnTooltipShow(INT uCode
, LPNMHDR hdr
, BOOL
& bHandled
);
149 BEGIN_MSG_MAP(CNotifyToolbar
)
150 MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST
, WM_MOUSELAST
, OnMouseEvent
)
151 NOTIFY_CODE_HANDLER(TTN_SHOW
, OnTooltipShow
)
154 void Initialize(HWND hWndParent
, CBalloonQueue
* queue
);
157 extern const WCHAR szSysPagerWndClass
[];
160 public CComObjectRootEx
<CComMultiThreadModelNoCS
>,
161 public CWindowImpl
< CSysPagerWnd
, CWindow
, CControlWinTraits
>,
164 CNotifyToolbar Toolbar
;
165 CTooltips m_Balloons
;
166 CBalloonQueue m_BalloonQueue
;
170 virtual ~CSysPagerWnd();
172 LRESULT
DrawBackground(HDC hdc
);
173 LRESULT
OnEraseBackground(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
174 LRESULT
OnCreate(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
175 LRESULT
OnDestroy(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
176 LRESULT
OnGetInfoTip(INT uCode
, LPNMHDR hdr
, BOOL
& bHandled
);
177 LRESULT
OnCustomDraw(INT uCode
, LPNMHDR hdr
, BOOL
& bHandled
);
178 LRESULT
OnSize(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
179 LRESULT
OnCtxMenu(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
180 LRESULT
OnBalloonPop(UINT uCode
, LPNMHDR hdr
, BOOL
& bHandled
);
181 LRESULT
OnTimer(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
184 BOOL
NotifyIconCmd(WPARAM wParam
, LPARAM lParam
);
185 void GetSize(IN BOOL IsHorizontal
, IN PSIZE size
);
186 void ResizeImagelist();
188 DECLARE_WND_CLASS_EX(szSysPagerWndClass
, CS_DBLCLKS
, COLOR_3DFACE
)
190 BEGIN_MSG_MAP(CSysPagerWnd
)
191 MESSAGE_HANDLER(WM_CREATE
, OnCreate
)
192 MESSAGE_HANDLER(WM_DESTROY
, OnDestroy
)
193 MESSAGE_HANDLER(WM_ERASEBKGND
, OnEraseBackground
)
194 MESSAGE_HANDLER(WM_SIZE
, OnSize
)
195 MESSAGE_HANDLER(WM_CONTEXTMENU
, OnCtxMenu
)
196 MESSAGE_HANDLER(WM_TIMER
, OnTimer
)
197 NOTIFY_CODE_HANDLER(TTN_POP
, OnBalloonPop
)
198 NOTIFY_CODE_HANDLER(TBN_GETINFOTIPW
, OnGetInfoTip
)
199 NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW
, OnCustomDraw
)
202 HWND
_Init(IN HWND hWndParent
, IN BOOL bVisible
);