From 387982285a95671a83cb0c48ab9c8a4a6b3cb222 Mon Sep 17 00:00:00 2001 From: Superxwolf Date: Mon, 6 Dec 2021 12:02:16 -0400 Subject: [PATCH] feature(windows): Add the tray icon when a new taskbar is created. --- tray/src/core/windows/tray.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tray/src/core/windows/tray.cpp b/tray/src/core/windows/tray.cpp index 3811108..333af1b 100755 --- a/tray/src/core/windows/tray.cpp +++ b/tray/src/core/windows/tray.cpp @@ -13,6 +13,7 @@ #include static constexpr auto WM_TRAY = WM_USER + 1; +const static auto WM_TASKBARCREATED = RegisterWindowMessage("TaskbarCreated"); std::map> Tray::Tray::trayList; Tray::Tray::Tray(std::string identifier, Icon icon) : BaseTray(std::move(identifier), icon) @@ -205,6 +206,14 @@ LRESULT CALLBACK Tray::Tray::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } } break; + default: + if (msg == WM_TASKBARCREATED) + { + auto &menu = trayList.at(hwnd).get(); + if (Shell_NotifyIcon(NIM_ADD, &menu.notifyData) == FALSE) + throw std::runtime_error("Failed to register tray icon on taskbar created"); + } + break; } return DefWindowProc(hwnd, msg, wParam, lParam); }