1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#include <precomp.h>
#ifdef WIN32
#include <windows.h>
#include <shellapi.h>
#endif
#include "systray.h"
#include <bfc/assert.h>
#include <bfc/wasabi_std.h>
Systray::Systray(HWND wnd, int uid, int msg, HICON smallicon)
{
id = uid;
hwnd = wnd;
message = msg;
icon = smallicon;
/*int r = */addIcon();
// always asserts with desktop with no systray support (litestep, WINE, etc...)
// ASSERT(r == TRUE);
}
Systray::~Systray()
{
/*int r = */deleteIcon();
// always asserts with desktop with no systray support (litestep, WINE, etc...)
// ASSERT(r == TRUE);
}
void Systray::setTip(const wchar_t *_tip)
{
tip = _tip;
tip.trunc(64);
if (!tip.isempty())
{
/*int r = */setTip();
// always asserts with desktop with no systray support (litestep, WINE, etc...)
// ASSERT(r == TRUE);
}
}
bool Systray::addIcon()
{
#ifdef WIN32
NOTIFYICONDATAW tnid = {0};
tnid.cbSize = sizeof(NOTIFYICONDATAW);
tnid.uID = id;
tnid.hWnd = hwnd;
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
tnid.uCallbackMessage = message;
tnid.hIcon = icon;
if (tip)
WCSCPYN(tnid.szTip, tip, sizeof(tnid.szTip)/sizeof(wchar_t));
return !!Shell_NotifyIconW(NIM_ADD, &tnid);
#else
DebugString("portme Systray::addIcon\n");
return 1;
#endif
}
bool Systray::setTip()
{
#ifdef WIN32
NOTIFYICONDATAW tnid = {0};
tnid.cbSize = sizeof(NOTIFYICONDATAW);
tnid.uFlags = NIF_TIP;
tnid.uID = id;
tnid.hWnd = hwnd;
if (tip)
WCSCPYN(tnid.szTip, tip, sizeof(tnid.szTip)/sizeof(wchar_t));
return !!Shell_NotifyIconW(NIM_MODIFY, &tnid);
#else
DebugString("portme Systray::setTip\n");
return 1;
#endif
}
bool Systray::deleteIcon()
{
#ifdef WIN32
NOTIFYICONDATA tnid = {0};
tnid.cbSize = sizeof(NOTIFYICONDATAW);
tnid.hWnd = hwnd;
tnid.uID = id;
return !!Shell_NotifyIcon(NIM_DELETE, &tnid);
#else
DebugString("portme Systray::deleteIcon\n");
return 1;
#endif
}
|