libnick 2024.12.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
notifyicon.h
Go to the documentation of this file.
1
23#ifdef _WIN32
24#ifndef NOTIFYICON_H
25#define NOTIFYICON_H
26
27#define _CRT_SECURE_NO_WARNINGS
28#define WM_NOTIFYICON_EVENT (WM_APP + 100)
29#define IDM_CONTEXT_MENU (WM_APP + 200)
30
31#include <filesystem>
32#include <unordered_map>
33#include <windows.h>
34#include <shellapi.h>
35#include "notifyiconmenu.h"
37
39{
44 class NotifyIcon
45 {
46 public:
55 NotifyIcon(HWND hwnd, const std::wstring& tooltip, const NotifyIconMenu& contextMenu = { }, bool hidden = false);
59 ~NotifyIcon();
64 bool hide();
69 bool show();
74 const std::wstring& getTooltip() const;
80 bool setTooltip(const std::wstring& tooltip);
85 const NotifyIconMenu& getContextMenu() const;
91 bool setContextMenu(const NotifyIconMenu& menu);
98 bool notify(const ShellNotificationSentEventArgs& e);
99
100 public:
106 static NotifyIcon* getFromHWND(HWND hwnd);
107
108 private:
113 NOTIFYICONDATAW getBaseNotifyIconData();
118 bool createContextMenu();
125 LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
126 std::wstring m_className;
127 bool m_isHidden;
128 std::wstring m_tooltip;
129 NotifyIconMenu m_contextMenu;
130 HWND m_hwnd;
131 GUID m_guid;
132 HMENU m_hmenu;
133 std::filesystem::path m_openPath;
134
135 private:
136 static std::unordered_map<HWND, NotifyIcon*> m_icons;
144 static LRESULT CALLBACK notifyIconWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
145 };
146}
147
148#endif //NOTIFYICON_H
149#endif
Definition notificationsenteventargs.h:31