[idd] helper: fix notification icon creation on explorer start

This commit is contained in:
Quantum
2025-11-08 21:41:22 -05:00
committed by Geoffrey McRae
parent f9ecddab98
commit ed1602fc74

View File

@@ -51,6 +51,7 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
case WM_NOTIFY_ICON: case WM_NOTIFY_ICON:
return onNotifyIcon(LOWORD(lParam), HIWORD(lParam), GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam)); return onNotifyIcon(LOWORD(lParam), HIWORD(lParam), GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam));
case WM_CLEAN_UP_CONFIG: case WM_CLEAN_UP_CONFIG:
if (m_config && !m_config->hwnd()) if (m_config && !m_config->hwnd())
{ {
@@ -58,6 +59,7 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
m_config.reset(); m_config.reset();
} }
return 0; return 0;
default: default:
if (s_taskbarCreated && uMsg == s_taskbarCreated) if (s_taskbarCreated && uMsg == s_taskbarCreated)
{ {
@@ -70,6 +72,9 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT CNotifyWindow::onCreate() LRESULT CNotifyWindow::onCreate()
{ {
// Allow explorer to send us this message to register the notification icon.
ChangeWindowMessageFilterEx(m_hwnd, s_taskbarCreated, MSGFLT_ALLOW, NULL);
registerIcon(); registerIcon();
return 0; return 0;
} }
@@ -129,7 +134,10 @@ void CNotifyWindow::registerIcon()
StringCbCopy(m_iconData.szTip, sizeof m_iconData.szTip, L"Looking Glass (IDD)"); StringCbCopy(m_iconData.szTip, sizeof m_iconData.szTip, L"Looking Glass (IDD)");
if (!Shell_NotifyIcon(NIM_ADD, &m_iconData)) if (!Shell_NotifyIcon(NIM_ADD, &m_iconData))
{
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_ADD)"); DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_ADD)");
return;
}
if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData)) if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData))
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)"); DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)");