Windows notify
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 56s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 56s
This commit is contained in:
@@ -376,6 +376,7 @@ public:
|
||||
/// @param title The notification title.
|
||||
/// @param content The actual text of the notification.
|
||||
/// @param icon The path to the icon to be displayed on the notification, Empty for none.
|
||||
/// @note On Windows, icon must be a .ico
|
||||
bool Notify(const std::string& title, const std::string& content, const std::filesystem::path& icon = "");
|
||||
|
||||
/// @returns True if we are definitely running on a software renderer.
|
||||
|
@@ -16,6 +16,42 @@ public:
|
||||
|
||||
using namespace ReWindow;
|
||||
|
||||
// TODO destroy n_data after it's no longer shown. Destroying it early causes the notification to come from explorer.
|
||||
bool RWindow::Notify(const std::string& title, const std::string& content, const std::filesystem::path& icon) {
|
||||
NOTIFYICONDATA n_data = {};
|
||||
HICON n_icon = nullptr;
|
||||
|
||||
if (!icon.empty()) {
|
||||
n_icon = (HICON) LoadImageW(
|
||||
nullptr,
|
||||
icon.c_str(),
|
||||
IMAGE_ICON,
|
||||
0, 0,
|
||||
LR_LOADFROMFILE | LR_DEFAULTSIZE
|
||||
);
|
||||
|
||||
if (!n_icon)
|
||||
return false;
|
||||
}
|
||||
|
||||
n_data.cbSize = sizeof(NOTIFYICONDATA);
|
||||
n_data.hWnd = platform->hwnd;
|
||||
n_data.uID = 1;
|
||||
n_data.uFlags = NIF_INFO | NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
n_data.uCallbackMessage = WM_USER + 1;
|
||||
n_data.hIcon = n_icon;
|
||||
lstrcpy(n_data.szTip, title.c_str());
|
||||
lstrcpy(n_data.szInfo, content.c_str());
|
||||
lstrcpy(n_data.szInfoTitle, title.c_str());
|
||||
n_data.dwInfoFlags = NIIF_USER;
|
||||
|
||||
Shell_NotifyIcon(NIM_ADD, &n_data);
|
||||
Shell_NotifyIcon(NIM_MODIFY, &n_data);
|
||||
|
||||
//Shell_NotifyIcon(NIM_DELETE, &n_data);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RWindow::SetSize(int newWidth, int newHeight) {
|
||||
if (!resizable)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user