12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- ////////////////////////////////////////////////////////////////
- // CTrayIcon Copyright 1996 Microsoft Systems Journal.
- //
- // If this code works, it was written by Paul DiLascia.
- // If not, I don't know who wrote it.
- #ifndef _ZEROT_TRAYICON_H
- #define _ZEROT_TRAYICON_H
- ////////////////
- #define MYWM_SHOWMINBOX WM_USER + 2 // 自定义消息,显示迷你对话框;
- // CTrayIcon manages an icon in the Windows 95 system tray.
- class ITrayIcon : public CCmdTarget
- {
- protected:
- DECLARE_DYNAMIC(ITrayIcon)
- NOTIFYICONDATA m_nid; // struct for Shell_NotifyIcon args
- public:
- ITrayIcon(UINT uID);
- ~ITrayIcon();
- // Call this to receive tray notifications
- void SetNotificationWnd(CWnd* pNotifyWnd, UINT uCbMsg);
- // SetIcon functions. To remove icon, call SetIcon(0)
- BOOL SetIcon(UINT uID); // only set the icon,but without tip zt.
- BOOL SetIcon(HICON hicon, LPCTSTR lpTip);
- BOOL SetIcon(UINT uID, LPCTSTR lpTip);
- BOOL SetIcon(LPCTSTR lpResName, LPCTSTR lpTip)
- {
- return SetIcon(lpResName ? AfxGetApp()->LoadIcon(lpResName) : NULL, lpTip);
- }
- // 设置提示(设置提示时,是否也要同时设置图标???);
- BOOL SetTip(LPCTSTR lpTip);
- //BOOL SetInfo(LPCSTR lpInfo,LPCSTR lpInfoTitle = _T("")); // NIF_INFO
- BOOL SetInfo(LPCTSTR lpInfo,LPCTSTR lpInfoTitle = NULL); // NIF_INFO
- BOOL SetStandardIcon(LPCTSTR lpszIconName, LPCTSTR lpTip)
- {
- return SetIcon(::LoadIcon(NULL, lpszIconName), lpTip);
- }
- virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent);
- // -------------------------------以下是托盘闪烁实现------------------------------- [5/30/2013 Z.t]
- public:
- bool IsFlashing(){return bSuspending;} // 外部调用,判断是否在闪烁;
- void SetMiniShow(BOOL bSet){bShowMinibox = bSet;}
- BOOL StartFlashing();
- BOOL StopFlashing();
- inline void SetIconInfos(const UINT &u1,const UINT &u2,const UINT &u3);
- inline void SetDefaultTip(LPCTSTR lpTip){_lpTip=lpTip;}
- protected:
- bool bSuspending; // 线程运行标识;
-
- LPCTSTR _lpTip; // 默认的提示;
- UINT _utIcon[3]; // 1.停止闪烁时的默认图标;2.闪烁时的报警图标;3.闪烁时的盘里背景图标;
- DWORD m_dwThreadID; // 线程ID;
- HANDLE m_hThreadCtrl; // 线程控件事件;
- HANDLE m_hThreadObj; // 线程本身;
- BOOL bShowMinibox; // 闪烁期间,是否对窗口发送消息;
- void GetTrayRect(RECT &rc);
- BOOL IsWow64();
- // 托盘闪烁线程;
- int OpendThread();
- void TerminalThread();
- static DWORD WINAPI FlashingThread(LPVOID pVoid);
- };
- inline void ITrayIcon::SetIconInfos(const UINT &u1,const UINT &u2,const UINT &u3)
- {
- _utIcon[0] = u1;
- _utIcon[1] = u2;
- _utIcon[2] = u3;
- }
- #endif
- // 未处理的BUG:
- // 1.在任务管理器中结束进程,托盘图标未能清除;
- // SetIcon(0)代表着清除托盘图标(NIF_DELETE);
|