if (oldIconVisible) {
NOTIFYICONDATA tnid{0};
tnid.cbSize = sizeof(NOTIFYICONDATA);
- tnid.uVersion = NOTIFYICON_VERSION_4;
tnid.hWnd = hWnd_;
tnid.uID = trayID_;
tnid.hIcon = hIcon_;
}
NOTIFYICONDATAW tnid{0};
tnid.cbSize = sizeof(tnid);
- tnid.uVersion = NOTIFYICON_VERSION_4;
tnid.hWnd = hWnd_;
tnid.uID = trayID_;
tnid.uFlags = NIF_INFO | NIF_SHOWTIP;
tnid.dwInfoFlags =
NIIF_INFO | NIIF_NOSOUND | NIIF_LARGE_ICON | NIIF_RESPECT_QUIET_TIME;
- tnid.uTimeout = 10 * 1000;
StringCchCopy(tnid.szInfoTitle, ARRAY_SIZE(tnid.szInfoTitle),
title.c_str());
StringCchCopy(tnid.szInfo, ARRAY_SIZE(tnid.szInfo), text.c_str());
if (SUCCEEDED(StringCchCopy(tnid.szTip, ARRAY_SIZE(tnid.szTip),
tooltip_.c_str())))
{
- DWORD result = Shell_NotifyIconW(NIM_ADD, &tnid);
- if (result == 0) {
+ BOOL result = Shell_NotifyIconW(NIM_ADD, &tnid);
+ if (result) {
+ // Opt in to NOTIFYICON_VERSION_4 message semantics; uVersion is
+ // only honored by NIM_SETVERSION.
result = Shell_NotifyIconW(NIM_SETVERSION, &tnid);
}
- return result != 0;
+ return result != FALSE;
}
return false;
}
{
NOTIFYICONDATAW tnid{0};
tnid.cbSize = sizeof(tnid);
- tnid.uVersion = NOTIFYICON_VERSION_4;
tnid.hWnd = hWnd_;
tnid.uID = trayID_;
{
NOTIFYICONDATAW tnid{0};
tnid.cbSize = sizeof(tnid);
- tnid.uVersion = NOTIFYICON_VERSION_4;
tnid.hWnd = hWnd_;
tnid.uID = trayID_;
tnid.uFlags = NIF_TIP;
} else {
muteCtrl_.SetMuteOnBluetoothDisconnect(true);
const bool muteOnWithDeviceList = settings_.QueryValue(SettingsKey::MUTE_ON_BLUETOOTH_DEVICELIST);
- btDetector_.SetDeviceList(settings_.GetBluetoothDevicesA(), muteOnWithDeviceList);
+ btDetector_.SetDeviceList(settings_.GetBluetoothDevices(), muteOnWithDeviceList);
}
}
return 0;
}
-LRESULT WinMute::OnTrayIcon(HWND hWnd, WPARAM, LPARAM lParam)
+LRESULT WinMute::OnTrayIcon(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
- if (LOWORD(lParam) == WM_CONTEXTMENU ||
- lParam == WM_LBUTTONUP ||
- lParam == WM_RBUTTONUP) {
- POINT p = { 0 };
- GetCursorPos(&p);
+ // NOTIFYICON_VERSION_4 semantics: LOWORD(lParam) carries the event,
+ // HIWORD(lParam) the icon ID and wParam the anchor coordinates.
+ const UINT event = LOWORD(lParam);
+ if (event == WM_CONTEXTMENU ||
+ event == NIN_SELECT ||
+ event == NIN_KEYSELECT) {
+ const POINT p{ GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam) };
SetForegroundWindow(hWnd);
TrackPopupMenuEx(
GetSubMenu(hTrayMenu_, 0),
LRESULT WinMute::OnUpdatePopup(HWND hWnd, WPARAM, LPARAM lParam)
{
- if (lParam == NIN_BALLOONUSERCLICK) {
+ // NOTIFYICON_VERSION_4 semantics: LOWORD(lParam) carries the event.
+ const UINT event = LOWORD(lParam);
+ if (event == NIN_BALLOONUSERCLICK) {
const bool betaUpdates = settings_.QueryValue(SettingsKey::CHECK_FOR_BETA_UPDATE) != 0;
if (betaUpdates && updateInfo_.beta.shouldUpdate) {
LaunchBrowser(hWnd, updateInfo_.beta.downloadUrl);
LaunchBrowser(hWnd, updateInfo_.stable.downloadUrl);
}
}
- if (lParam == NIN_BALLOONHIDE || lParam == NIN_BALLOONTIMEOUT || lParam == NIN_BALLOONUSERCLICK) {
+ if (event == NIN_BALLOONHIDE || event == NIN_BALLOONTIMEOUT || event == NIN_BALLOONUSERCLICK) {
updateTray_.Hide();
}
return 0;