ReactOS  0.4.15-dev-1384-g878186b
CSysTray Class Reference

#include <csystray.h>

Inheritance diagram for CSysTray:
Collaboration diagram for CSysTray:

Public Member Functions

HRESULT NotifyIcon (INT code, UINT uId, HICON hIcon, LPCWSTR szTip, DWORD dwstate=0)
 
HWND GetHWnd ()
 
VOID EnableService (DWORD dwServiceFlag, BOOL bEnable)
 
BOOL IsServiceEnabled (DWORD dwServiceFlag)
 
 CSysTray ()
 
virtual ~CSysTray ()
 
virtual HRESULT STDMETHODCALLTYPE QueryStatus (const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
 
virtual HRESULT STDMETHODCALLTYPE Exec (const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Protected Member Functions

BOOL ProcessWindowMessage (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD dwMsgMapID=0)
 

Private Member Functions

HRESULT SysTrayMessageLoop ()
 
HRESULT SysTrayThreadProc ()
 
HRESULT CreateSysTrayThread ()
 
HRESULT DestroySysTrayWindow ()
 
HRESULT InitIcons ()
 
HRESULT ShutdownIcons ()
 
HRESULT UpdateIcons ()
 
HRESULT ProcessIconMessage (UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 
HRESULT InitNetShell ()
 
HRESULT ShutdownNetShell ()
 
VOID GetServicesEnabled ()
 

Static Private Member Functions

static DWORD WINAPI s_SysTrayThreadProc (PVOID param)
 

Private Attributes

CComPtr< IOleCommandTargetpctNetShell
 
DWORD dwServicesEnabled
 
HWND hwndSysTray
 

Additional Inherited Members

- Public Types inherited from IOleCommandTarget
enum  OLECMDF {
  OLECMDF_SUPPORTED = 0x1, OLECMDF_ENABLED = 0x2, OLECMDF_LATCHED = 0x4, OLECMDF_NINCHED = 0x8,
  OLECMDF_INVISIBLE = 0x10, OLECMDF_DEFHIDEONCTXTMENU = 0x20
}
 
enum  OLECMDTEXTF { OLECMDTEXTF_NONE = 0, OLECMDTEXTF_NAME = 1, OLECMDTEXTF_STATUS = 2 }
 
enum  OLECMDEXECOPT { OLECMDEXECOPT_DODEFAULT = 0, OLECMDEXECOPT_PROMPTUSER = 1, OLECMDEXECOPT_DONTPROMPTUSER = 2, OLECMDEXECOPT_SHOWHELP = 3 }
 
enum  OLECMDID {
  OLECMDID_OPEN = 1, OLECMDID_NEW = 2, OLECMDID_SAVE = 3, OLECMDID_SAVEAS = 4,
  OLECMDID_SAVECOPYAS = 5, OLECMDID_PRINT = 6, OLECMDID_PRINTPREVIEW = 7, OLECMDID_PAGESETUP = 8,
  OLECMDID_SPELL = 9, OLECMDID_PROPERTIES = 10, OLECMDID_CUT = 11, OLECMDID_COPY = 12,
  OLECMDID_PASTE = 13, OLECMDID_PASTESPECIAL = 14, OLECMDID_UNDO = 15, OLECMDID_REDO = 16,
  OLECMDID_SELECTALL = 17, OLECMDID_CLEARSELECTION = 18, OLECMDID_ZOOM = 19, OLECMDID_GETZOOMRANGE = 20,
  OLECMDID_UPDATECOMMANDS = 21, OLECMDID_REFRESH = 22, OLECMDID_STOP = 23, OLECMDID_HIDETOOLBARS = 24,
  OLECMDID_SETPROGRESSMAX = 25, OLECMDID_SETPROGRESSPOS = 26, OLECMDID_SETPROGRESSTEXT = 27, OLECMDID_SETTITLE = 28,
  OLECMDID_SETDOWNLOADSTATE = 29, OLECMDID_STOPDOWNLOAD = 30, OLECMDID_ONTOOLBARACTIVATED = 31, OLECMDID_FIND = 32,
  OLECMDID_DELETE = 33, OLECMDID_HTTPEQUIV = 34, OLECMDID_HTTPEQUIV_DONE = 35, OLECMDID_ENABLE_INTERACTION = 36,
  OLECMDID_ONUNLOAD = 37, OLECMDID_PROPERTYBAG2 = 38, OLECMDID_PREREFRESH = 39, OLECMDID_SHOWSCRIPTERROR = 40,
  OLECMDID_SHOWMESSAGE = 41, OLECMDID_SHOWFIND = 42, OLECMDID_SHOWPAGESETUP = 43, OLECMDID_SHOWPRINT = 44,
  OLECMDID_CLOSE = 45, OLECMDID_ALLOWUILESSSAVEAS = 46, OLECMDID_DONTDOWNLOADCSS = 47, OLECMDID_UPDATEPAGESTATUS = 48,
  OLECMDID_PRINT2 = 49, OLECMDID_PRINTPREVIEW2 = 50, OLECMDID_SETPRINTTEMPLATE = 51, OLECMDID_GETPRINTTEMPLATE = 52,
  OLECMDID_PAGEACTIONBLOCKED = 55, OLECMDID_PAGEACTIONUIQUERY = 56, OLECMDID_FOCUSVIEWCONTROLS = 57, OLECMDID_FOCUSVIEWCONTROLSQUERY = 58,
  OLECMDID_SHOWPAGEACTIONMENU = 59, OLECMDID_ADDTRAVELENTRY = 60, OLECMDID_UPDATETRAVELENTRY = 61, OLECMDID_UPDATEBACKFORWARDSTATE = 62,
  OLECMDID_OPTICAL_ZOOM = 63, OLECMDID_OPTICAL_GETZOOMRANGE = 64, OLECMDID_WINDOWSTATECHANGED = 65, OLECMDID_ACTIVEXINSTALLSCOPE = 66,
  OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67, OLECMDID_SHOWTASKDLG = 68, OLECMDID_POPSTATEEVENT = 69, OLECMDID_VIEWPORT_MODE = 70,
  OLECMDID_LAYOUT_VIEWPORT_WIDTH = 71, OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM = 72, OLECMDID_USER_OPTICAL_ZOOM = 73, OLECMDID_PAGEAVAILABLE = 74,
  OLECMDID_GETUSERSCALABLE = 75, OLECMDID_UPDATE_CARET = 76, OLECMDID_ENABLE_VISIBILITY = 77, OLECMDID_MEDIA_PLAYBACK = 78
}
 
typedef IOleCommandTargetLPOLECOMMANDTARGET
 
typedef enum IOleCommandTarget::OLECMDF OLECMDF
 
typedef struct IOleCommandTarget::_tagOLECMD OLECMD
 
typedef struct IOleCommandTarget::_tagOLECMDTEXT OLECMDTEXT
 
typedef enum IOleCommandTarget::OLECMDTEXTF OLECMDTEXTF
 
typedef enum IOleCommandTarget::OLECMDEXECOPT OLECMDEXECOPT
 
typedef enum IOleCommandTarget::OLECMDID OLECMDID
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 21 of file csystray.h.

Constructor & Destructor Documentation

◆ CSysTray()

CSysTray::CSysTray ( )

Definition at line 22 of file csystray.cpp.

22 {}

◆ ~CSysTray()

CSysTray::~CSysTray ( )
virtual

Definition at line 23 of file csystray.cpp.

23 {}

Member Function Documentation

◆ CreateSysTrayThread()

HRESULT CSysTray::CreateSysTrayThread ( )
private

Definition at line 259 of file csystray.cpp.

260 {
261  TRACE("CSysTray Init TODO: Initialize tray icon handlers.\n");
262 
264 
266 
267  return S_OK;
268 }
static DWORD WINAPI s_SysTrayThreadProc(PVOID param)
Definition: csystray.cpp:219
#define CloseHandle
Definition: compat.h:598
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
HANDLE hThread
Definition: wizard.c:27

Referenced by Exec().

◆ DestroySysTrayWindow()

HRESULT CSysTray::DestroySysTrayWindow ( )
private

Definition at line 270 of file csystray.cpp.

271 {
272  DestroyWindow();
273  hwndSysTray = NULL;
274  return S_OK;
275 }
HWND hwndSysTray
Definition: csystray.h:32
BOOL WINAPI DestroyWindow(_In_ HWND)
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112

Referenced by Exec().

◆ EnableService()

VOID CSysTray::EnableService ( DWORD  dwServiceFlag,
BOOL  bEnable 
)

Definition at line 55 of file csystray.cpp.

56 {
57  HKEY hKey;
58 
59  if (bEnable)
60  this->dwServicesEnabled |= dwServiceFlag;
61  else
62  this->dwServicesEnabled &= ~dwServiceFlag;
63 
65  L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\SysTray",
66  0,
67  NULL,
69  KEY_WRITE,
70  NULL,
71  &hKey,
72  NULL) == ERROR_SUCCESS)
73  {
75  L"Services",
76  0,
77  REG_DWORD,
78  (LPBYTE)&this->dwServicesEnabled,
79  sizeof(DWORD));
80 
82  }
83 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
DWORD dwServicesEnabled
Definition: csystray.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
_In_ BOOL bEnable
Definition: winddi.h:3426
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define REG_DWORD
Definition: sdbapi.c:596

◆ Exec()

HRESULT STDMETHODCALLTYPE CSysTray::Exec ( const GUID pguidCmdGroup,
DWORD  nCmdID,
DWORD  nCmdexecopt,
VARIANT pvaIn,
VARIANT pvaOut 
)
virtual

Implements IOleCommandTarget.

Definition at line 284 of file csystray.cpp.

285 {
286  if (!IsEqualGUID(*pguidCmdGroup, CGID_ShellServiceObject))
287  return E_FAIL;
288 
289  switch (nCmdID)
290  {
291  case OLECMDID_NEW: // init
292  return CreateSysTrayThread();
293  case OLECMDID_SAVE: // shutdown
294  return DestroySysTrayWindow();
295  }
296  return S_OK;
297 }
HRESULT CreateSysTrayThread()
Definition: csystray.cpp:259
#define E_FAIL
Definition: ddrawi.h:102
HRESULT DestroySysTrayWindow()
Definition: csystray.cpp:270
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ GetHWnd()

HWND CSysTray::GetHWnd ( )
inline

Definition at line 53 of file csystray.h.

53 { return m_hWnd; }

Referenced by _RunHotplug(), _ShowContextMenu(), _ShowContextMenuR(), NotifyBalloon(), and ShowPowerSchemesPopupMenu().

◆ GetServicesEnabled()

VOID CSysTray::GetServicesEnabled ( )
private

Definition at line 25 of file csystray.cpp.

26 {
27  HKEY hKey;
28  DWORD dwSize;
29 
30  /* Enable power, volume and hotplug by default */
32 
34  L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\SysTray",
35  0,
36  NULL,
38  KEY_READ,
39  NULL,
40  &hKey,
41  NULL) == ERROR_SUCCESS)
42  {
43  dwSize = sizeof(DWORD);
45  L"Services",
46  NULL,
47  NULL,
48  (LPBYTE)&this->dwServicesEnabled,
49  &dwSize);
50 
52  }
53 }
#define POWER_SERVICE_FLAG
Definition: precomp.h:37
#define HOTPLUG_SERVICE_FLAG
Definition: precomp.h:38
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
DWORD dwServicesEnabled
Definition: csystray.h:31
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define VOLUME_SERVICE_FLAG
Definition: precomp.h:39
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by ProcessWindowMessage().

◆ InitIcons()

HRESULT CSysTray::InitIcons ( )
private

Definition at line 112 of file csystray.cpp.

113 {
114  TRACE("Initializing Notification icons...\n");
115  for (int i = 0; i < g_NumIcons; i++)
116  {
117  if (this->dwServicesEnabled & g_IconHandlers[i].dwServiceFlag)
118  {
119  HRESULT hr = g_IconHandlers[i].pfnInit(this);
120  if (FAILED(hr))
121  return hr;
122  }
123  }
124 
125  return InitNetShell();
126 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT InitNetShell()
Definition: csystray.cpp:90
const int g_NumIcons
Definition: csystray.cpp:20
SysTrayIconHandlers_t g_IconHandlers[]
Definition: csystray.cpp:15
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwServicesEnabled
Definition: csystray.h:31
LONG HRESULT
Definition: typedefs.h:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PFNSTINIT pfnInit
Definition: precomp.h:51

Referenced by ProcessWindowMessage().

◆ InitNetShell()

HRESULT CSysTray::InitNetShell ( )
private

Definition at line 90 of file csystray.cpp.

91 {
92  HRESULT hr = CoCreateInstance(CLSID_ConnectionTray, 0, 1u, IID_PPV_ARG(IOleCommandTarget, &pctNetShell));
93  if (FAILED(hr))
94  return hr;
95 
96  return pctNetShell->Exec(&CGID_ShellServiceObject,
99 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
LONG HRESULT
Definition: typedefs.h:79
CComPtr< IOleCommandTarget > pctNetShell
Definition: csystray.h:27
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define NULL
Definition: types.h:112

Referenced by InitIcons().

◆ IsServiceEnabled()

BOOL CSysTray::IsServiceEnabled ( DWORD  dwServiceFlag)

Definition at line 85 of file csystray.cpp.

86 {
87  return (this->dwServicesEnabled & dwServiceFlag);
88 }
DWORD dwServicesEnabled
Definition: csystray.h:31

◆ NotifyIcon()

HRESULT CSysTray::NotifyIcon ( INT  code,
UINT  uId,
HICON  hIcon,
LPCWSTR  szTip,
DWORD  dwstate = 0 
)

Definition at line 196 of file csystray.cpp.

197 {
198  NOTIFYICONDATA nim = { 0 };
199 
200  TRACE("NotifyIcon code=%d, uId=%d, hIcon=%p, szTip=%S\n", code, uId, hIcon, szTip);
201 
202  nim.cbSize = sizeof(nim);
203  nim.uFlags = NIF_MESSAGE | NIF_ICON | NIF_STATE | NIF_TIP;
204  nim.hIcon = hIcon;
205  nim.uID = uId;
206  nim.uCallbackMessage = uId;
207  nim.dwState = dwstate;
208  nim.dwStateMask = NIS_HIDDEN;
209  nim.hWnd = m_hWnd;
210  nim.uVersion = NOTIFYICON_VERSION;
211  if (szTip)
212  StringCchCopy(nim.szTip, _countof(nim.szTip), szTip);
213  else
214  nim.szTip[0] = 0;
215  BOOL ret = Shell_NotifyIcon(code, &nim);
216  return ret ? S_OK : E_FAIL;
217 }
#define NIF_MESSAGE
Definition: shellapi.h:102
#define E_FAIL
Definition: ddrawi.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD dwStateMask
Definition: shellapi.h:237
CHAR szTip[128]
Definition: shellapi.h:235
#define NIF_TIP
Definition: shellapi.h:104
#define NIF_ICON
Definition: shellapi.h:103
#define TRACE(s)
Definition: solgame.cpp:4
#define _countof(array)
Definition: sndvol32.h:68
int ret
#define StringCchCopy
Definition: strsafe.h:139
Definition: inflate.c:139
UINT uCallbackMessage
Definition: shellapi.h:229
#define S_OK
Definition: intsafe.h:51
HICON hIcon
Definition: msconfig.c:44
#define Shell_NotifyIcon
Definition: shellapi.h:689

◆ ProcessIconMessage()

HRESULT CSysTray::ProcessIconMessage ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT lResult 
)
private

Definition at line 160 of file csystray.cpp.

161 {
162  for (int i = 0; i < g_NumIcons; i++)
163  {
164  HRESULT hr = g_IconHandlers[i].pfnMessage(this, uMsg, wParam, lParam, lResult);
165  if (FAILED(hr))
166  return hr;
167 
168  if (hr == S_OK)
169  return hr;
170  }
171 
172  // Not handled by anyone, so return accordingly.
173  return S_FALSE;
174 }
HRESULT hr
Definition: shlfolder.c:183
const int g_NumIcons
Definition: csystray.cpp:20
SysTrayIconHandlers_t g_IconHandlers[]
Definition: csystray.cpp:15
WPARAM wParam
Definition: combotst.c:138
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PFNSTMESSAGE pfnMessage
Definition: precomp.h:54
LPARAM lParam
Definition: combotst.c:139

Referenced by ProcessWindowMessage().

◆ ProcessWindowMessage()

BOOL CSysTray::ProcessWindowMessage ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT lResult,
DWORD  dwMsgMapID = 0 
)
protected

Definition at line 299 of file csystray.cpp.

300 {
301  HRESULT hr;
302 
303  if (hWnd != m_hWnd)
304  return FALSE;
305 
306  switch (uMsg)
307  {
308  case WM_NCCREATE:
309  case WM_NCDESTROY:
310  return FALSE;
311 
312  case WM_CREATE:
314  InitIcons();
315  SetTimer(1, 2000, NULL);
316  return TRUE;
317 
318  case WM_TIMER:
319  if (wParam == 1)
320  UpdateIcons();
321  else
322  ProcessIconMessage(uMsg, wParam, lParam, lResult);
323  return TRUE;
324 
325  case WM_DESTROY:
326  KillTimer(1);
327  ShutdownIcons();
328  return TRUE;
329  }
330 
331  TRACE("SysTray message received %u (%08p %08p)\n", uMsg, wParam, lParam);
332 
333  hr = ProcessIconMessage(uMsg, wParam, lParam, lResult);
334  if (FAILED(hr))
335  return FALSE;
336 
337  return (hr == S_OK);
338 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define WM_TIMER
Definition: winuser.h:1724
#define WM_NCDESTROY
Definition: winuser.h:1666
HRESULT ShutdownIcons()
Definition: csystray.cpp:128
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define S_OK
Definition: intsafe.h:51
HRESULT ProcessIconMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
Definition: csystray.cpp:160
HRESULT InitIcons()
Definition: csystray.cpp:112
HRESULT UpdateIcons()
Definition: csystray.cpp:144
#define NULL
Definition: types.h:112
VOID GetServicesEnabled()
Definition: csystray.cpp:25
#define WM_CREATE
Definition: winuser.h:1590
LPARAM lParam
Definition: combotst.c:139

◆ QueryStatus()

HRESULT STDMETHODCALLTYPE CSysTray::QueryStatus ( const GUID pguidCmdGroup,
ULONG  cCmds,
OLECMD  prgCmds[],
OLECMDTEXT pCmdText 
)
virtual

Implements IOleCommandTarget.

Definition at line 278 of file csystray.cpp.

279 {
281  return S_OK;
282 }
#define S_OK
Definition: intsafe.h:51
#define UNIMPLEMENTED
Definition: debug.h:115

◆ s_SysTrayThreadProc()

DWORD WINAPI CSysTray::s_SysTrayThreadProc ( PVOID  param)
staticprivate

Definition at line 219 of file csystray.cpp.

220 {
221  CSysTray * st = (CSysTray*) param;
222  return st->SysTrayThreadProc();
223 }
GLfloat param
Definition: glext.h:5796
HRESULT SysTrayThreadProc()
Definition: csystray.cpp:242

Referenced by CreateSysTrayThread().

◆ ShutdownIcons()

HRESULT CSysTray::ShutdownIcons ( )
private

Definition at line 128 of file csystray.cpp.

129 {
130  TRACE("Shutting down Notification icons...\n");
131  for (int i = 0; i < g_NumIcons; i++)
132  {
133  if (this->dwServicesEnabled & g_IconHandlers[i].dwServiceFlag)
134  {
136  if (FAILED(hr))
137  return hr;
138  }
139  }
140 
141  return ShutdownNetShell();
142 }
HRESULT hr
Definition: shlfolder.c:183
const int g_NumIcons
Definition: csystray.cpp:20
SysTrayIconHandlers_t g_IconHandlers[]
Definition: csystray.cpp:15
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwServicesEnabled
Definition: csystray.h:31
LONG HRESULT
Definition: typedefs.h:79
HRESULT ShutdownNetShell()
Definition: csystray.cpp:101
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PFNSTSHUTDOWN pfnShutdown
Definition: precomp.h:52

Referenced by ProcessWindowMessage().

◆ ShutdownNetShell()

HRESULT CSysTray::ShutdownNetShell ( )
private

Definition at line 101 of file csystray.cpp.

102 {
103  if (!pctNetShell)
104  return S_FALSE;
105  HRESULT hr = pctNetShell->Exec(&CGID_ShellServiceObject,
108  pctNetShell.Release();
109  return hr;
110 }
HRESULT hr
Definition: shlfolder.c:183
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:79
CComPtr< IOleCommandTarget > pctNetShell
Definition: csystray.h:27
#define NULL
Definition: types.h:112

Referenced by ShutdownIcons().

◆ SysTrayMessageLoop()

HRESULT CSysTray::SysTrayMessageLoop ( )
private

Definition at line 225 of file csystray.cpp.

226 {
227  BOOL ret;
228  MSG msg;
229 
230  while ((ret = GetMessage(&msg, NULL, 0, 0)) != 0)
231  {
232  if (ret < 0)
233  break;
234 
237  }
238 
239  return S_OK;
240 }
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
#define GetMessage
Definition: winuser.h:5765
#define msg(x)
Definition: auth_time.c:54

Referenced by SysTrayThreadProc().

◆ SysTrayThreadProc()

HRESULT CSysTray::SysTrayThreadProc ( )
private

Definition at line 242 of file csystray.cpp.

243 {
244  WCHAR strFileName[MAX_PATH];
245  GetModuleFileNameW(g_hInstance, strFileName, MAX_PATH);
246  HMODULE hLib = LoadLibraryW(strFileName);
247 
249 
250  Create(NULL);
251 
253 
254  CoUninitialize();
255 
257 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
_In_ BOOLEAN Create
Definition: pstypes.h:519
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:507
#define LoadLibraryW(x)
Definition: compat.h:606
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
int ret
HRESULT SysTrayMessageLoop()
Definition: csystray.cpp:225
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
#define NULL
Definition: types.h:112
HINSTANCE g_hInstance
Definition: MainWindow.cpp:18

Referenced by s_SysTrayThreadProc().

◆ UpdateIcons()

HRESULT CSysTray::UpdateIcons ( )
private

Definition at line 144 of file csystray.cpp.

145 {
146  TRACE("Updating Notification icons...\n");
147  for (int i = 0; i < g_NumIcons; i++)
148  {
149  if (this->dwServicesEnabled & g_IconHandlers[i].dwServiceFlag)
150  {
152  if (FAILED(hr))
153  return hr;
154  }
155  }
156 
157  return S_OK;
158 }
HRESULT hr
Definition: shlfolder.c:183
const int g_NumIcons
Definition: csystray.cpp:20
SysTrayIconHandlers_t g_IconHandlers[]
Definition: csystray.cpp:15
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwServicesEnabled
Definition: csystray.h:31
LONG HRESULT
Definition: typedefs.h:79
PFNSTUPDATE pfnUpdate
Definition: precomp.h:53
#define S_OK
Definition: intsafe.h:51
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by ProcessWindowMessage().

Member Data Documentation

◆ dwServicesEnabled

DWORD CSysTray::dwServicesEnabled
private

◆ hwndSysTray

HWND CSysTray::hwndSysTray
private

Definition at line 32 of file csystray.h.

Referenced by DestroySysTrayWindow().

◆ pctNetShell

CComPtr<IOleCommandTarget> CSysTray::pctNetShell
private

Definition at line 27 of file csystray.h.

Referenced by InitNetShell(), and ShutdownNetShell().


The documentation for this class was generated from the following files: