From c7b1c35f21dac6a3df3c288dd9f0ac9a80e9b5f9 Mon Sep 17 00:00:00 2001 From: Reinder Feenstra Date: Tue, 10 May 2022 23:45:21 +0200 Subject: [PATCH] windows: added tooltip with server version to system tray icon --- server/src/os/windows/trayicon.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/os/windows/trayicon.cpp b/server/src/os/windows/trayicon.cpp index 9c5308b5..74411f40 100644 --- a/server/src/os/windows/trayicon.cpp +++ b/server/src/os/windows/trayicon.cpp @@ -22,6 +22,8 @@ #include "trayicon.hpp" #include +#include +#include #include "../../core/eventloop.hpp" #include "../../traintastic/traintastic.hpp" @@ -76,9 +78,11 @@ void TrayIcon::run() notifyIconData.cbSize = sizeof(notifyIconData); notifyIconData.hWnd = s_window; notifyIconData.uID = 0; - notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE; + notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_SHOWTIP; notifyIconData.uCallbackMessage = WM_NOTIFYICON_CALLBACK; notifyIconData.hIcon = static_cast(LoadImageA(GetModuleHandleA(nullptr), "APPICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE)); + const std::string_view toolTip{"Traintastic server v" TRAINTASTIC_VERSION " " TRAINTASTIC_CODENAME}; + std::strncpy(notifyIconData.szTip, toolTip.data(), std::min(toolTip.size(), sizeof(notifyIconData.szTip) - 1)); const std::string_view infoTitle{"Traintastic server"}; const std::string_view infoMessage{"Traintastic server is running in the system tray."};