Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.0 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: TrayIcon.h
  4. //
  5. // Module: CMMON32.EXE
  6. //
  7. // Synopsis: CTrayIcon class definition, which manages the connection tray icon
  8. //
  9. // Copyright (c) 1998-1999 Microsoft Corporation
  10. //
  11. // Author: fengsun Created 02/17/98
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef TRAYICON_H
  15. #define TRAYICON_H
  16. #include "ArrayPtr.h"
  17. class CIni;
  18. //+---------------------------------------------------------------------------
  19. //
  20. // class CTrayIcon
  21. //
  22. // Description: A class to manage tray icon
  23. //
  24. // History: fengsun Created 2/17/98
  25. //
  26. //----------------------------------------------------------------------------
  27. class CTrayIcon
  28. {
  29. public:
  30. CTrayIcon();
  31. ~CTrayIcon();
  32. void SetIcon(HICON hIcon, HWND hwnd, UINT uMsg, UINT uID, const TCHAR* lpMsg = NULL);
  33. // void SetTip(const TCHAR* lpMsg);
  34. void RemoveIcon();
  35. void CreateMenu(const CIni* pIniFile, DWORD dwMsgBase);
  36. void PopupMenu(int x, int y, HWND hWnd);
  37. const TCHAR* GetMenuCommand(int i) const;
  38. int GetAdditionalMenuNum() const;
  39. protected:
  40. HMENU m_hMenu; // the IDM_TARY menu in the resource
  41. HMENU m_hSubMenu; // the first sub menu of IDM_TRAY
  42. HWND m_hwnd; // the window handle for the tray icon
  43. UINT m_uID; // the ID of the tray icon
  44. HICON m_hIcon; // the tray icon handle
  45. CPtrArray m_CommandArray; // array of LPTSTR menu item command line
  46. };
  47. inline void CTrayIcon::PopupMenu(int x, int y, HWND hWnd)
  48. {
  49. SetMenuDefaultItem(m_hSubMenu, IDMC_TRAY_STATUS, FALSE);
  50. MYVERIFY(TrackPopupMenu(m_hSubMenu,TPM_LEFTALIGN|TPM_RIGHTBUTTON,x,y,0,hWnd,NULL));
  51. }
  52. inline const TCHAR* CTrayIcon::GetMenuCommand(int i) const
  53. {
  54. return (const TCHAR*) m_CommandArray[i];
  55. }
  56. inline int CTrayIcon::GetAdditionalMenuNum() const
  57. {
  58. return m_CommandArray.GetSize();
  59. }
  60. #endif