SShellNofityHwnd2.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "core\SimpleWnd.h"
  3. #include "helper\SMenu.h"
  4. //添加一个事件接收窗口用于专门处理托盘图标
  5. #ifndef WM_ICONNOTIFY
  6. #define WM_ICONNOTIFY (WM_USER + 1111)
  7. #endif // !WM_ICONNOTIFY
  8. #ifndef ID_TASKBARICON
  9. #define ID_TASKBARICON 100
  10. #endif // !ID_TASKBARICON
  11. #define ANI_TIMER_ID 8
  12. #include "SShellNotifyIcon.h"
  13. #define CHAIN_MSG_MAP_MEMBER_PTR(theChainMember) \
  14. { \
  15. bHandled=FALSE;BOOL bCanChain=TRUE;\
  16. if(theChainMember==nullptr||((uMsg!=WM_ICONNOTIFY)&&(uMsg!=WM_COMMAND)))\
  17. bCanChain=FALSE;\
  18. if(bCanChain&&theChainMember->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult)) \
  19. bHandled=TRUE; \
  20. if(bHandled)\
  21. return TRUE;\
  22. }
  23. #if _MSC_VER<1600
  24. #define nullptr NULL
  25. #endif
  26. namespace SOUI
  27. {
  28. class SShellNotifyIcon;
  29. class CShellNotifyHwnd2 :public CSimpleWnd
  30. {
  31. public:
  32. CShellNotifyHwnd2(SHostWnd* pMainWnd,SShellNotifyIcon* shellnotifyicon);
  33. ~CShellNotifyHwnd2(){}
  34. protected:
  35. //托盘通知消息处理函数
  36. LRESULT OnIconNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL/* bHandled*/);
  37. LRESULT OnTaskbarCreated(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL);
  38. virtual void OnFinalMessage(HWND hWnd);
  39. void OnTimer(UINT_PTR nIDEvent);
  40. BEGIN_MSG_MAP_EX(CShellNotifyHwnd2)
  41. //托盘消息处理
  42. MESSAGE_HANDLER(MsgTaskbarCreated, OnTaskbarCreated)
  43. MSG_WM_TIMER(OnTimer)
  44. CHAIN_MSG_MAP_MEMBER_PTR(m_pMainWnd)
  45. MESSAGE_HANDLER(WM_ICONNOTIFY, OnIconNotify)
  46. CHAIN_MSG_MAP(CSimpleWnd)
  47. END_MSG_MAP()
  48. private:
  49. SHostWnd *m_pMainWnd;
  50. SShellNotifyIcon *m_ShellNotifyIcon;
  51. UINT MsgTaskbarCreated;
  52. };
  53. }