ReactOS  0.4.13-dev-249-gcba1a2f
precomp.h File Reference
#include <stdarg.h>
#include <tchar.h>
#include <windef.h>
#include <winbase.h>
#include <shlguid_undoc.h>
#include <shlobj.h>
#include <strsafe.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atlstr.h>
#include <setupapi.h>
#include <shellapi.h>
#include <wine/debug.h>
#include "resource.h"
#include "csystray.h"
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SysTrayIconHandlers_t
 

Macros

#define WIN32_NO_STATUS
 
#define COBJMACROS
 
#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define NTOS_MODE_USER
 
#define ID_ICON_VOLUME   (WM_APP + 0x4CB)
 
#define ID_ICON_HOTPLUG   (WM_APP + 0x4CC)
 
#define ID_ICON_POWER   (WM_APP + 0x4CD)
 
#define POWER_SERVICE_FLAG   0x00000001
 
#define HOTPLUG_SERVICE_FLAG   0x00000002
 
#define VOLUME_SERVICE_FLAG   0x00000004
 
#define POWER_TIMER_ID   2
 
#define VOLUME_TIMER_ID   3
 
#define HOTPLUG_TIMER_ID   4
 

Typedefs

typedef HRESULT(STDMETHODCALLTYPEPFNSTINIT) (_In_ CSysTray *pSysTray)
 
typedef HRESULT(STDMETHODCALLTYPEPFNSTSHUTDOWN) (_In_ CSysTray *pSysTray)
 
typedef HRESULT(STDMETHODCALLTYPEPFNSTUPDATE) (_In_ CSysTray *pSysTray)
 
typedef HRESULT(STDMETHODCALLTYPEPFNSTMESSAGE) (_In_ CSysTray *pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (stobject)
 
HRESULT STDMETHODCALLTYPE Volume_Init (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Volume_Shutdown (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Volume_Update (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Volume_Message (_In_ CSysTray *pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 
HRESULT STDMETHODCALLTYPE Hotplug_Init (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Hotplug_Shutdown (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Hotplug_Update (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Hotplug_Message (_In_ CSysTray *pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 
HRESULT STDMETHODCALLTYPE Power_Init (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Power_Shutdown (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Power_Update (_In_ CSysTray *pSysTray)
 
HRESULT STDMETHODCALLTYPE Power_Message (_In_ CSysTray *pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 

Variables

HINSTANCE g_hInstance
 
SysTrayIconHandlers_t g_IconHandlers []
 
const int g_NumIcons
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 10 of file precomp.h.

◆ COBJMACROS

#define COBJMACROS

Definition at line 8 of file precomp.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 11 of file precomp.h.

◆ HOTPLUG_SERVICE_FLAG

#define HOTPLUG_SERVICE_FLAG   0x00000002

Definition at line 38 of file precomp.h.

◆ HOTPLUG_TIMER_ID

#define HOTPLUG_TIMER_ID   4

Definition at line 79 of file precomp.h.

◆ ID_ICON_HOTPLUG

#define ID_ICON_HOTPLUG   (WM_APP + 0x4CC)

Definition at line 34 of file precomp.h.

◆ ID_ICON_POWER

#define ID_ICON_POWER   (WM_APP + 0x4CD)

Definition at line 35 of file precomp.h.

◆ ID_ICON_VOLUME

#define ID_ICON_VOLUME   (WM_APP + 0x4CB)

Definition at line 33 of file precomp.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 12 of file precomp.h.

◆ POWER_SERVICE_FLAG

#define POWER_SERVICE_FLAG   0x00000001

Definition at line 37 of file precomp.h.

◆ POWER_TIMER_ID

#define POWER_TIMER_ID   2

Definition at line 77 of file precomp.h.

◆ VOLUME_SERVICE_FLAG

#define VOLUME_SERVICE_FLAG   0x00000004

Definition at line 39 of file precomp.h.

◆ VOLUME_TIMER_ID

#define VOLUME_TIMER_ID   3

Definition at line 78 of file precomp.h.

◆ WIN32_NO_STATUS [1/2]

#define WIN32_NO_STATUS

Definition at line 9 of file precomp.h.

◆ WIN32_NO_STATUS [2/2]

#define WIN32_NO_STATUS

Definition at line 9 of file precomp.h.

Typedef Documentation

◆ PFNSTINIT

typedef HRESULT(STDMETHODCALLTYPE * PFNSTINIT) (_In_ CSysTray *pSysTray)

Definition at line 43 of file precomp.h.

◆ PFNSTMESSAGE

typedef HRESULT(STDMETHODCALLTYPE * PFNSTMESSAGE) (_In_ CSysTray *pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)

Definition at line 46 of file precomp.h.

◆ PFNSTSHUTDOWN

typedef HRESULT(STDMETHODCALLTYPE * PFNSTSHUTDOWN) (_In_ CSysTray *pSysTray)

Definition at line 44 of file precomp.h.

◆ PFNSTUPDATE

typedef HRESULT(STDMETHODCALLTYPE * PFNSTUPDATE) (_In_ CSysTray *pSysTray)

Definition at line 45 of file precomp.h.

Function Documentation

◆ Hotplug_Init()

HRESULT STDMETHODCALLTYPE Hotplug_Init ( _In_ CSysTray pSysTray)

Definition at line 130 of file hotplug.cpp.

131 {
132  TRACE("Hotplug_Init\n");
135 
136  return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip, NIS_HIDDEN);
137 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON g_hIconHotplug
Definition: hotplug.cpp:22
#define ID_ICON_HOTPLUG
Definition: precomp.h:34
static LPCWSTR g_strTooltip
Definition: hotplug.cpp:23
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT EnumHotpluggedDevices(CSimpleArray< DEVINST > &devList)
Definition: hotplug.cpp:38
CSimpleArray< DEVINST > g_devList
Definition: hotplug.cpp:20
#define NIM_ADD
Definition: shellapi.h:91
#define LoadIcon
Definition: winuser.h:5679
HINSTANCE g_hInstance
Definition: MainWindow.cpp:18
#define IDI_HOTPLUG_OK
Definition: resource.h:57

Referenced by Hotplug_Message().

◆ Hotplug_Message()

HRESULT STDMETHODCALLTYPE Hotplug_Message ( _In_ CSysTray pSysTray,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT lResult 
)

Definition at line 237 of file hotplug.cpp.

238 {
239  HRESULT hr = E_FAIL;
240  TRACE("Hotplug_Message uMsg=%d, wParam=%x, lParam=%x\n", uMsg, wParam, lParam);
241 
242  switch (uMsg)
243  {
244  /*case WM_CREATE:
245  TRACE("Hotplug_Message: WM_CREATE\n");
246  DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
247 
248  ZeroMemory(&NotificationFilter, sizeof(NotificationFilter));
249  NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
250  NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
251 
252  g_hDevNotify = RegisterDeviceNotification(pSysTray->GetHWnd(), &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
253  if (g_hDevNotify != NULL)
254  {
255  lResult = true;
256  return S_OK;
257  }
258  return S_FALSE;*/
259 
260  case WM_USER + 220:
261  TRACE("Hotplug_Message: WM_USER+220\n");
263  {
264  if (lParam)
265  {
266  pSysTray->EnableService(HOTPLUG_SERVICE_FLAG, TRUE);
267  return Hotplug_Init(pSysTray);
268  }
269  else
270  {
271  pSysTray->EnableService(HOTPLUG_SERVICE_FLAG, FALSE);
272  return Hotplug_Shutdown(pSysTray);
273  }
274  }
275  return S_FALSE;
276 
277  case WM_USER + 221:
278  TRACE("Hotplug_Message: WM_USER+221\n");
280  {
281  lResult = (LRESULT)pSysTray->IsServiceEnabled(HOTPLUG_SERVICE_FLAG);
282  return S_OK;
283  }
284  return S_FALSE;
285 
286  case WM_TIMER:
287  if (wParam == HOTPLUG_TIMER_ID)
288  {
289  KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
290  _ShowContextMenu(pSysTray);
291  }
292  break;
293 
294  case ID_ICON_HOTPLUG:
295  Hotplug_Update(pSysTray);
296 
297  switch (lParam)
298  {
299  case WM_LBUTTONDOWN:
300  SetTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID, GetDoubleClickTime(), NULL);
301  break;
302 
303  case WM_LBUTTONUP:
304  break;
305 
306  case WM_LBUTTONDBLCLK:
307  KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
308  _RunHotplug(pSysTray);
309  break;
310 
311  case WM_RBUTTONDOWN:
312  break;
313 
314  case WM_RBUTTONUP:
315  _ShowContextMenuR(pSysTray);
316  break;
317 
318  case WM_RBUTTONDBLCLK:
319  break;
320 
321  case WM_MOUSEMOVE:
322  break;
323  }
324  return S_OK;
325 
326  case WM_DEVICECHANGE:
327  switch (wParam)
328  {
331  if (FAILED(hr))
332  return hr;
333 
334  lResult = true;
335  break;
336  case DBT_DEVICEARRIVAL:
337  break;
339  break;
341  break;
343  WCHAR strInfo[128];
344  swprintf(strInfo, L"The %wS can now be safely removed from the system.", g_strMenuSel);
345  NotifyBalloon(pSysTray, L"Safe to Remove Hardware", strInfo);
346 
347  lResult = true;
348  break;
350  break;
351  }
352  return S_OK;
353 
354  /*case WM_CLOSE:
355  if (!UnregisterDeviceNotification(hDeviceNotify))
356  {
357  return S_FALSE;
358  }
359  return S_OK;*/
360 
361  default:
362  TRACE("Hotplug_Message received for unknown ID %d, ignoring.\n");
363  return S_FALSE;
364  }
365 
366  return S_FALSE;
367 }
#define HOTPLUG_SERVICE_FLAG
Definition: precomp.h:38
static void _RunHotplug(CSysTray *pSysTray)
Definition: hotplug.cpp:156
static void _ShowContextMenu(CSysTray *pSysTray)
Definition: hotplug.cpp:161
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
#define DBT_DEVNODES_CHANGED
Definition: dbt.h:28
HRESULT hr
Definition: shlfolder.c:183
#define ID_ICON_HOTPLUG
Definition: precomp.h:34
#define E_FAIL
Definition: ddrawi.h:102
WPARAM wParam
Definition: combotst.c:138
#define DBT_DEVICEREMOVECOMPLETE
Definition: dbt.h:16
HRESULT STDMETHODCALLTYPE Hotplug_Init(_In_ CSysTray *pSysTray)
Definition: hotplug.cpp:130
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT STDMETHODCALLTYPE Hotplug_Shutdown(_In_ CSysTray *pSysTray)
Definition: hotplug.cpp:149
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define WM_TIMER
Definition: winuser.h:1718
#define DBT_DEVICEQUERYREMOVE
Definition: dbt.h:13
HRESULT EnumHotpluggedDevices(CSimpleArray< DEVINST > &devList)
Definition: hotplug.cpp:38
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WM_RBUTTONUP
Definition: winuser.h:1756
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define DBT_DEVICEQUERYREMOVEFAILED
Definition: dbt.h:14
static const WCHAR L[]
Definition: oid.c:1250
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
#define LRESULT
Definition: ole.h:14
#define WM_USER
Definition: winuser.h:1856
#define S_OK
Definition: intsafe.h:59
CSimpleArray< DEVINST > g_devList
Definition: hotplug.cpp:20
static WCHAR g_strMenuSel[DISPLAY_NAME_LEN]
Definition: hotplug.cpp:24
HRESULT STDMETHODCALLTYPE Hotplug_Update(_In_ CSysTray *pSysTray)
Definition: hotplug.cpp:139
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define DBT_DEVICEARRIVAL
Definition: dbt.h:12
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define WM_DEVICECHANGE
Definition: winuser.h:1787
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define DBT_DEVICEREMOVEPENDING
Definition: dbt.h:15
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
#define HOTPLUG_TIMER_ID
Definition: precomp.h:79
HRESULT NotifyBalloon(CSysTray *pSysTray, LPCWSTR szTitle=NULL, LPCWSTR szInfo=NULL, UINT uId=ID_ICON_HOTPLUG)
Definition: hotplug.cpp:100
LPARAM lParam
Definition: combotst.c:139
static void _ShowContextMenuR(CSysTray *pSysTray)
Definition: hotplug.cpp:213

◆ Hotplug_Shutdown()

HRESULT STDMETHODCALLTYPE Hotplug_Shutdown ( _In_ CSysTray pSysTray)

Definition at line 149 of file hotplug.cpp.

150 {
151  TRACE("Hotplug_Shutdown\n");
152 
153  return pSysTray->NotifyIcon(NIM_DELETE, ID_ICON_HOTPLUG, NULL, NULL);
154 }
#define ID_ICON_HOTPLUG
Definition: precomp.h:34
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define NIM_DELETE
Definition: shellapi.h:93

Referenced by Hotplug_Message().

◆ Hotplug_Update()

HRESULT STDMETHODCALLTYPE Hotplug_Update ( _In_ CSysTray pSysTray)

Definition at line 139 of file hotplug.cpp.

140 {
141  TRACE("Hotplug_Update\n");
142 
143  if(g_devList.GetSize() || g_IsRemoving)
144  return pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip);
145  else
146  return pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip, NIS_HIDDEN);
147 }
static HICON g_hIconHotplug
Definition: hotplug.cpp:22
#define ID_ICON_HOTPLUG
Definition: precomp.h:34
static LPCWSTR g_strTooltip
Definition: hotplug.cpp:23
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL g_IsRemoving
Definition: hotplug.cpp:25
CSimpleArray< DEVINST > g_devList
Definition: hotplug.cpp:20
#define NIM_MODIFY
Definition: shellapi.h:92

Referenced by Hotplug_Message().

◆ Power_Init()

HRESULT STDMETHODCALLTYPE Power_Init ( _In_ CSysTray pSysTray)

Definition at line 115 of file power.cpp.

116 {
117  TRACE("Power_Init\n");
119 
120  return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_POWER, g_hIconBattery, g_strTooltip);
121 }
static HICON g_hIconBattery
Definition: power.cpp:30
#define TRACE(s)
Definition: solgame.cpp:4
#define ID_ICON_POWER
Definition: precomp.h:35
static HICON DynamicLoadIcon(HINSTANCE hinst)
Definition: power.cpp:77
#define NIM_ADD
Definition: shellapi.h:91
CString g_strTooltip
Definition: power.cpp:29
HINSTANCE g_hInstance
Definition: MainWindow.cpp:18

Referenced by Power_Message().

◆ Power_Message()

HRESULT STDMETHODCALLTYPE Power_Message ( _In_ CSysTray pSysTray,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT lResult 
)

Definition at line 230 of file power.cpp.

231 {
232  TRACE("Power_Message uMsg=%d, wParam=%x, lParam=%x\n", uMsg, wParam, lParam);
233 
234  switch (uMsg)
235  {
236  case WM_USER + 220:
237  TRACE("Power_Message: WM_USER+220\n");
238  if (wParam == POWER_SERVICE_FLAG)
239  {
240  if (lParam)
241  {
242  pSysTray->EnableService(POWER_SERVICE_FLAG, TRUE);
243  return Power_Init(pSysTray);
244  }
245  else
246  {
247  pSysTray->EnableService(POWER_SERVICE_FLAG, FALSE);
248  return Power_Shutdown(pSysTray);
249  }
250  }
251  return S_FALSE;
252 
253  case WM_USER + 221:
254  TRACE("Power_Message: WM_USER+221\n");
255  if (wParam == POWER_SERVICE_FLAG)
256  {
257  lResult = (LRESULT)pSysTray->IsServiceEnabled(POWER_SERVICE_FLAG);
258  return S_OK;
259  }
260  return S_FALSE;
261 
262  case WM_TIMER:
263  if (wParam == POWER_TIMER_ID)
264  {
265  KillTimer(pSysTray->GetHWnd(), POWER_TIMER_ID);
266  ShowPowerSchemesPopupMenu(pSysTray);
267  }
268  break;
269 
270  case ID_ICON_POWER:
271  Power_Update(pSysTray);
272 
273  switch (lParam)
274  {
275  case WM_LBUTTONDOWN:
276  SetTimer(pSysTray->GetHWnd(), POWER_TIMER_ID, GetDoubleClickTime(), NULL);
277  break;
278 
279  case WM_LBUTTONUP:
280  break;
281 
282  case WM_LBUTTONDBLCLK:
283  KillTimer(pSysTray->GetHWnd(), POWER_TIMER_ID);
284  _RunPower();
285  break;
286 
287  case WM_RBUTTONDOWN:
288  break;
289 
290  case WM_RBUTTONUP:
291  _ShowContextMenu(pSysTray);
292  break;
293 
294  case WM_RBUTTONDBLCLK:
295  break;
296 
297  case WM_MOUSEMOVE:
298  break;
299  }
300  return S_OK;
301 
302  default:
303  TRACE("Power_Message received for unknown ID %d, ignoring.\n");
304  return S_FALSE;
305  }
306 
307  return S_FALSE;
308 }
#define POWER_SERVICE_FLAG
Definition: precomp.h:37
HRESULT STDMETHODCALLTYPE Power_Init(_In_ CSysTray *pSysTray)
Definition: power.cpp:115
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
HRESULT STDMETHODCALLTYPE Power_Update(_In_ CSysTray *pSysTray)
Definition: power.cpp:123
static void _ShowContextMenu(CSysTray *pSysTray)
Definition: power.cpp:143
WPARAM wParam
Definition: combotst.c:138
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
#define TRACE(s)
Definition: solgame.cpp:4
#define ID_ICON_POWER
Definition: precomp.h:35
#define WM_TIMER
Definition: winuser.h:1718
#define WM_RBUTTONUP
Definition: winuser.h:1756
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
#define LRESULT
Definition: ole.h:14
static VOID ShowPowerSchemesPopupMenu(CSysTray *pSysTray)
Definition: power.cpp:195
#define WM_USER
Definition: winuser.h:1856
#define S_OK
Definition: intsafe.h:59
#define POWER_TIMER_ID
Definition: precomp.h:77
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define WM_MOUSEMOVE
Definition: winuser.h:1751
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
HRESULT STDMETHODCALLTYPE Power_Shutdown(_In_ CSysTray *pSysTray)
Definition: power.cpp:131
LPARAM lParam
Definition: combotst.c:139
static void _RunPower()
Definition: power.cpp:138

◆ Power_Shutdown()

HRESULT STDMETHODCALLTYPE Power_Shutdown ( _In_ CSysTray pSysTray)

Definition at line 131 of file power.cpp.

132 {
133  TRACE("Power_Shutdown\n");
134 
135  return pSysTray->NotifyIcon(NIM_DELETE, ID_ICON_POWER, NULL, NULL);
136 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define ID_ICON_POWER
Definition: precomp.h:35
#define NIM_DELETE
Definition: shellapi.h:93

Referenced by Power_Message().

◆ Power_Update()

HRESULT STDMETHODCALLTYPE Power_Update ( _In_ CSysTray pSysTray)

Definition at line 123 of file power.cpp.

124 {
125  TRACE("Power_Update\n");
127 
128  return pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_POWER, g_hIconBattery, g_strTooltip);
129 }
static HICON g_hIconBattery
Definition: power.cpp:30
#define TRACE(s)
Definition: solgame.cpp:4
#define ID_ICON_POWER
Definition: precomp.h:35
static HICON DynamicLoadIcon(HINSTANCE hinst)
Definition: power.cpp:77
CString g_strTooltip
Definition: power.cpp:29
HINSTANCE g_hInstance
Definition: MainWindow.cpp:18
#define NIM_MODIFY
Definition: shellapi.h:92

Referenced by Power_Message().

◆ Volume_Init()

HRESULT STDMETHODCALLTYPE Volume_Init ( _In_ CSysTray pSysTray)

Definition at line 137 of file volume.cpp.

138 {
139  HRESULT hr;
140  WCHAR strTooltip[128];
141 
142  TRACE("Volume_Init\n");
143 
144  if (!g_hMixer)
145  {
146  hr = Volume_FindMixerControl(pSysTray);
147  if (FAILED(hr))
148  return hr;
149 
150  g_mmDeviceChange = RegisterWindowMessageW(L"winmm_devicechange");
151  }
152 
155 
156  Volume_IsMute();
157 
158  HICON icon;
159  if (g_IsMute)
160  icon = g_hIconMute;
161  else
162  icon = g_hIconVolume;
163 
164  LoadStringW(g_hInstance, IDS_VOL_VOLUME, strTooltip, _countof(strTooltip));
165  return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_VOLUME, icon, strTooltip);
166 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define IDI_VOLMUTE
Definition: resource.h:30
HRESULT hr
Definition: shlfolder.c:183
HRESULT Volume_IsMute()
Definition: volume.cpp:112
#define _countof(array)
Definition: fontsub.cpp:30
#define IDS_VOL_VOLUME
Definition: resource.h:32
UINT g_mmDeviceChange
Definition: volume.cpp:21
static HRESULT __stdcall Volume_FindMixerControl(CSysTray *pSysTray)
Definition: volume.cpp:25
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HICON g_hIconMute
Definition: volume.cpp:14
#define ID_ICON_VOLUME
Definition: precomp.h:38
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static BOOL g_IsMute
Definition: volume.cpp:23
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
HICON g_hIconVolume
Definition: volume.cpp:13
#define NIM_ADD
Definition: shellapi.h:91
HMIXER g_hMixer
Definition: volume.cpp:16
#define LoadIcon
Definition: winuser.h:5679
HINSTANCE g_hInstance
Definition: MainWindow.cpp:18
#define IDI_VOLUME
Definition: resource.h:29

Referenced by Volume_Message().

◆ Volume_Message()

HRESULT STDMETHODCALLTYPE Volume_Message ( _In_ CSysTray pSysTray,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT lResult 
)

Definition at line 256 of file volume.cpp.

257 {
258  if (uMsg == g_mmDeviceChange)
259  return Volume_OnDeviceChange(pSysTray, wParam, lParam);
260 
261  switch (uMsg)
262  {
263  case WM_USER + 220:
264  TRACE("Volume_Message: WM_USER+220\n");
266  {
267  if (lParam)
268  {
269  pSysTray->EnableService(VOLUME_SERVICE_FLAG, TRUE);
270  return Volume_Init(pSysTray);
271  }
272  else
273  {
274  pSysTray->EnableService(VOLUME_SERVICE_FLAG, FALSE);
275  return Volume_Shutdown(pSysTray);
276  }
277  }
278  return S_FALSE;
279 
280  case WM_USER + 221:
281  TRACE("Volume_Message: WM_USER+221\n");
283  {
284  lResult = (LRESULT)pSysTray->IsServiceEnabled(VOLUME_SERVICE_FLAG);
285  return S_OK;
286  }
287  return S_FALSE;
288 
289  case WM_TIMER:
290  if (wParam == VOLUME_TIMER_ID)
291  {
292  KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
293  _RunVolume(TRUE);
294  }
295  break;
296 
297  case ID_ICON_VOLUME:
298  TRACE("Volume_Message uMsg=%d, w=%x, l=%x\n", uMsg, wParam, lParam);
299 
300  Volume_Update(pSysTray);
301 
302  switch (lParam)
303  {
304  case WM_LBUTTONDOWN:
305  SetTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID, GetDoubleClickTime(), NULL);
306  break;
307 
308  case WM_LBUTTONUP:
309  break;
310 
311  case WM_LBUTTONDBLCLK:
312  KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
313  _RunVolume(FALSE);
314  break;
315 
316  case WM_RBUTTONDOWN:
317  break;
318 
319  case WM_RBUTTONUP:
320  _ShowContextMenu(pSysTray);
321  break;
322 
323  case WM_RBUTTONDBLCLK:
324  break;
325 
326  case WM_MOUSEMOVE:
327  break;
328  }
329  return S_OK;
330 
331  default:
332  TRACE("Volume_Message received for unknown ID %d, ignoring.\n");
333  return S_FALSE;
334  }
335 
336  return S_FALSE;
337 }
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
UINT g_mmDeviceChange
Definition: volume.cpp:21
WPARAM wParam
Definition: combotst.c:138
HRESULT STDMETHODCALLTYPE Volume_Update(_In_ CSysTray *pSysTray)
Definition: volume.cpp:168
#define ID_ICON_VOLUME
Definition: precomp.h:38
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
#define TRACE(s)
Definition: solgame.cpp:4
#define VOLUME_TIMER_ID
Definition: precomp.h:78
#define VOLUME_SERVICE_FLAG
Definition: precomp.h:39
#define WM_TIMER
Definition: winuser.h:1718
HRESULT Volume_OnDeviceChange(_In_ CSysTray *pSysTray, WPARAM wParam, LPARAM lParam)
Definition: volume.cpp:207
#define WM_RBUTTONUP
Definition: winuser.h:1756
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static void _RunVolume(BOOL bTray)
Definition: volume.cpp:212
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
#define LRESULT
Definition: ole.h:14
#define WM_USER
Definition: winuser.h:1856
#define S_OK
Definition: intsafe.h:59
#define WM_LBUTTONUP
Definition: winuser.h:1753
HRESULT STDMETHODCALLTYPE Volume_Init(_In_ CSysTray *pSysTray)
Definition: volume.cpp:137
#define WM_MOUSEMOVE
Definition: winuser.h:1751
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
HRESULT STDMETHODCALLTYPE Volume_Shutdown(_In_ CSysTray *pSysTray)
Definition: volume.cpp:200
static void _ShowContextMenu(CSysTray *pSysTray)
Definition: volume.cpp:222
LPARAM lParam
Definition: combotst.c:139

◆ Volume_Shutdown()

HRESULT STDMETHODCALLTYPE Volume_Shutdown ( _In_ CSysTray pSysTray)

Definition at line 200 of file volume.cpp.

201 {
202  TRACE("Volume_Shutdown\n");
203 
204  return pSysTray->NotifyIcon(NIM_DELETE, ID_ICON_VOLUME, NULL, NULL);
205 }
#define ID_ICON_VOLUME
Definition: precomp.h:38
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define NIM_DELETE
Definition: shellapi.h:93

Referenced by Volume_Message().

◆ Volume_Update()

HRESULT STDMETHODCALLTYPE Volume_Update ( _In_ CSysTray pSysTray)

Definition at line 168 of file volume.cpp.

169 {
170  BOOL PrevState;
171 
172  TRACE("Volume_Update\n");
173 
174  PrevState = g_IsMute;
175  Volume_IsMute();
176 
177  if (PrevState != g_IsMute)
178  {
179  WCHAR strTooltip[128];
180  HICON icon;
181  if (g_IsMute)
182  {
183  icon = g_hIconMute;
184  LoadStringW(g_hInstance, IDS_VOL_MUTED, strTooltip, _countof(strTooltip));
185  }
186  else
187  {
188  icon = g_hIconVolume;
189  LoadStringW(g_hInstance, IDS_VOL_VOLUME, strTooltip, _countof(strTooltip));
190  }
191 
192  return pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_VOLUME, icon, strTooltip);
193  }
194  else
195  {
196  return S_OK;
197  }
198 }
static HICON
Definition: imagelist.c:84
HRESULT Volume_IsMute()
Definition: volume.cpp:112
#define _countof(array)
Definition: fontsub.cpp:30
#define IDS_VOL_VOLUME
Definition: resource.h:32
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HICON g_hIconMute
Definition: volume.cpp:14
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ID_ICON_VOLUME
Definition: precomp.h:38
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL g_IsMute
Definition: volume.cpp:23
#define S_OK
Definition: intsafe.h:59
HICON g_hIconVolume
Definition: volume.cpp:13
#define IDS_VOL_MUTED
Definition: resource.h:36
HINSTANCE g_hInstance
Definition: MainWindow.cpp:18
#define NIM_MODIFY
Definition: shellapi.h:92

Referenced by Volume_Message().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( stobject  )

Variable Documentation

◆ g_hInstance

HINSTANCE g_hInstance

Definition at line 18 of file MainWindow.cpp.

◆ g_IconHandlers

◆ g_NumIcons