ReactOS  0.4.14-dev-57-g333b8f1
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:5714
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 242 of file hotplug.cpp.

243 {
244  HRESULT hr = E_FAIL;
245  TRACE("Hotplug_Message uMsg=%d, wParam=%x, lParam=%x\n", uMsg, wParam, lParam);
246 
247  switch (uMsg)
248  {
249  /*case WM_CREATE:
250  TRACE("Hotplug_Message: WM_CREATE\n");
251  DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
252 
253  ZeroMemory(&NotificationFilter, sizeof(NotificationFilter));
254  NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
255  NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
256 
257  g_hDevNotify = RegisterDeviceNotification(pSysTray->GetHWnd(), &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
258  if (g_hDevNotify != NULL)
259  {
260  lResult = true;
261  return S_OK;
262  }
263  return S_FALSE;*/
264 
265  case WM_USER + 220:
266  TRACE("Hotplug_Message: WM_USER+220\n");
268  {
269  if (lParam)
270  {
271  pSysTray->EnableService(HOTPLUG_SERVICE_FLAG, TRUE);
272  return Hotplug_Init(pSysTray);
273  }
274  else
275  {
276  pSysTray->EnableService(HOTPLUG_SERVICE_FLAG, FALSE);
277  return Hotplug_Shutdown(pSysTray);
278  }
279  }
280  return S_FALSE;
281 
282  case WM_USER + 221:
283  TRACE("Hotplug_Message: WM_USER+221\n");
285  {
286  lResult = (LRESULT)pSysTray->IsServiceEnabled(HOTPLUG_SERVICE_FLAG);
287  return S_OK;
288  }
289  return S_FALSE;
290 
291  case WM_TIMER:
292  if (wParam == HOTPLUG_TIMER_ID)
293  {
294  KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
295  _ShowContextMenu(pSysTray);
296  }
297  break;
298 
299  case ID_ICON_HOTPLUG:
300  Hotplug_Update(pSysTray);
301 
302  switch (lParam)
303  {
304  case WM_LBUTTONDOWN:
305  SetTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID, GetDoubleClickTime(), NULL);
306  break;
307 
308  case WM_LBUTTONUP:
309  break;
310 
311  case WM_LBUTTONDBLCLK:
312  KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
313  _RunHotplug(pSysTray);
314  break;
315 
316  case WM_RBUTTONDOWN:
317  break;
318 
319  case WM_RBUTTONUP:
320  _ShowContextMenuR(pSysTray);
321  break;
322 
323  case WM_RBUTTONDBLCLK:
324  break;
325 
326  case WM_MOUSEMOVE:
327  break;
328  }
329  return S_OK;
330 
331  case WM_DEVICECHANGE:
332  switch (wParam)
333  {
336  if (FAILED(hr))
337  return hr;
338 
339  lResult = true;
340  break;
341  case DBT_DEVICEARRIVAL:
342  break;
344  break;
346  break;
348  WCHAR strInfo[128];
349  swprintf(strInfo, L"The %wS can now be safely removed from the system.", g_strMenuSel);
350  NotifyBalloon(pSysTray, L"Safe to Remove Hardware", strInfo);
351 
352  lResult = true;
353  break;
355  break;
356  }
357  return S_OK;
358 
359  /*case WM_CLOSE:
360  if (!UnregisterDeviceNotification(hDeviceNotify))
361  {
362  return S_FALSE;
363  }
364  return S_OK;*/
365 
366  default:
367  TRACE("Hotplug_Message received for unknown ID %d, ignoring.\n");
368  return S_FALSE;
369  }
370 
371  return S_FALSE;
372 }
#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:166
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#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:1761
#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:1724
#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:1762
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:1760
#define LRESULT
Definition: ole.h:14
#define WM_USER
Definition: winuser.h:1877
#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:1759
#define DBT_DEVICEARRIVAL
Definition: dbt.h:12
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define WM_DEVICECHANGE
Definition: winuser.h:1793
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define DBT_DEVICEREMOVEPENDING
Definition: dbt.h:15
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1763
#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:218

◆ 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:1758
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:1761
#define TRACE(s)
Definition: solgame.cpp:4
#define ID_ICON_POWER
Definition: precomp.h:35
#define WM_TIMER
Definition: winuser.h:1724
#define WM_RBUTTONUP
Definition: winuser.h:1762
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
#define LRESULT
Definition: ole.h:14
static VOID ShowPowerSchemesPopupMenu(CSysTray *pSysTray)
Definition: power.cpp:195
#define WM_USER
Definition: winuser.h:1877
#define S_OK
Definition: intsafe.h:59
#define POWER_TIMER_ID
Definition: precomp.h:77
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MOUSEMOVE
Definition: winuser.h:1757
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1763
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:5714
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 261 of file volume.cpp.

262 {
263  if (uMsg == g_mmDeviceChange)
264  return Volume_OnDeviceChange(pSysTray, wParam, lParam);
265 
266  switch (uMsg)
267  {
268  case WM_USER + 220:
269  TRACE("Volume_Message: WM_USER+220\n");
271  {
272  if (lParam)
273  {
274  pSysTray->EnableService(VOLUME_SERVICE_FLAG, TRUE);
275  return Volume_Init(pSysTray);
276  }
277  else
278  {
279  pSysTray->EnableService(VOLUME_SERVICE_FLAG, FALSE);
280  return Volume_Shutdown(pSysTray);
281  }
282  }
283  return S_FALSE;
284 
285  case WM_USER + 221:
286  TRACE("Volume_Message: WM_USER+221\n");
288  {
289  lResult = (LRESULT)pSysTray->IsServiceEnabled(VOLUME_SERVICE_FLAG);
290  return S_OK;
291  }
292  return S_FALSE;
293 
294  case WM_TIMER:
295  if (wParam == VOLUME_TIMER_ID)
296  {
297  KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
298  _RunVolume(TRUE);
299  }
300  break;
301 
302  case ID_ICON_VOLUME:
303  TRACE("Volume_Message uMsg=%d, w=%x, l=%x\n", uMsg, wParam, lParam);
304 
305  Volume_Update(pSysTray);
306 
307  switch (lParam)
308  {
309  case WM_LBUTTONDOWN:
310  SetTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID, GetDoubleClickTime(), NULL);
311  break;
312 
313  case WM_LBUTTONUP:
314  break;
315 
316  case WM_LBUTTONDBLCLK:
317  KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
318  _RunVolume(FALSE);
319  break;
320 
321  case WM_RBUTTONDOWN:
322  break;
323 
324  case WM_RBUTTONUP:
325  _ShowContextMenu(pSysTray);
326  break;
327 
328  case WM_RBUTTONDBLCLK:
329  break;
330 
331  case WM_MOUSEMOVE:
332  break;
333  }
334  return S_OK;
335 
336  default:
337  TRACE("Volume_Message received for unknown ID %d, ignoring.\n");
338  return S_FALSE;
339  }
340 
341  return S_FALSE;
342 }
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
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:1761
#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:1724
HRESULT Volume_OnDeviceChange(_In_ CSysTray *pSysTray, WPARAM wParam, LPARAM lParam)
Definition: volume.cpp:207
#define WM_RBUTTONUP
Definition: winuser.h:1762
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static void _RunVolume(BOOL bTray)
Definition: volume.cpp:212
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
#define LRESULT
Definition: ole.h:14
#define WM_USER
Definition: winuser.h:1877
#define S_OK
Definition: intsafe.h:59
#define WM_LBUTTONUP
Definition: winuser.h:1759
HRESULT STDMETHODCALLTYPE Volume_Init(_In_ CSysTray *pSysTray)
Definition: volume.cpp:137
#define WM_MOUSEMOVE
Definition: winuser.h:1757
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1763
HRESULT STDMETHODCALLTYPE Volume_Shutdown(_In_ CSysTray *pSysTray)
Definition: volume.cpp:200
static void _ShowContextMenu(CSysTray *pSysTray)
Definition: volume.cpp:227
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