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
|
/*
* Copyright (C) Igor Sysoev
*/
#include <ngx_config.h>
#include <ngx_core.h>
#define NGX_MAX_TEXT 2048
void ngx_cdecl ngx_message_box(char *title, ngx_uint_t type, ngx_err_t err,
const char *fmt, ...)
{
va_list args;
u_char text[NGX_MAX_TEXT], *p, *last;
last = text + NGX_MAX_TEXT;
va_start(args, fmt);
p = ngx_vsnprintf(text, NGX_MAX_TEXT, fmt, args);
va_end(args);
if (err) {
if (p > last - 50) {
/* leave a space for an error code */
p = last - 50;
*p++ = '.';
*p++ = '.';
*p++ = '.';
}
if ((unsigned) err >= 0x80000000) {
p = ngx_snprintf(p, last - p, " (%Xd: ", err);
} else {
p = ngx_snprintf(p, last - p, " (%d: ", err);
}
p = ngx_strerror_r(err, p, last - p);
if (p < last) {
*p++ = ')';
}
}
if (p == last) {
p--;
}
*p = '\0';
MessageBox(NULL, (char *) text, title, type);
}
ngx_int_t
ngx_system_tray_icon(HWND window, u_long action, HICON icon, u_char *tip)
{
NOTIFYICONDATA ni;
ni.cbSize = sizeof(NOTIFYICONDATA);
ni.hWnd = window;
ni.uID = 0;
ni.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
ni.uCallbackMessage = NGX_WM_TRAY;
ni.hIcon = icon;
if (tip) {
ngx_cpystrn((u_char *) ni.szTip, tip, 64);
} else {
ni.szTip[0] = '\0';
}
if (Shell_NotifyIcon(action, &ni) == 0) {
return NGX_ERROR;
}
return NGX_OK;
}
|