-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwconmsg.cpp
More file actions
134 lines (106 loc) · 2.3 KB
/
Copy pathwconmsg.cpp
File metadata and controls
134 lines (106 loc) · 2.3 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#define WIN32_LEAN_AND_MEAN
#include <winstrct.h>
EXTERN_C
int
WINAPI
ConsoleMessageA(
HWND,
LPCSTR lpText,
LPCSTR lpCaption,
UINT uType)
{
FILE *stream;
switch (uType & MB_ICONMASK)
{
case MB_ICONASTERISK:
case MB_ICONHAND:
case MB_SERVICE_NOTIFICATION:
stream = stderr;
break;
default:
stream = stdout;
}
LPCSTR prompt = NULL;
LPCSTR buttons = NULL;
switch (uType & MB_TYPEMASK)
{
case MB_CANCELTRYCONTINUE:
prompt = "(C)ancel, (T)ry again, Contin(u)e?";
buttons = "CTU";
break;
case MB_RETRYCANCEL:
prompt = "(R)etry, (C)ancel?";
buttons = "RC";
break;
case MB_YESNO:
prompt = "(Y)es, (N)o?";
buttons = "YN";
break;
case MB_YESNOCANCEL:
prompt = "(Y)es, (N)o, (C)ancel?";
buttons = "YNC";
break;
case MB_ABORTRETRYIGNORE:
prompt = "(A)bort, (R)etry, (I)gnore?";
buttons = "ARI";
break;
case MB_OKCANCEL:
prompt = "(O)K, (C)ancel?";
buttons = "OC";
break;
}
fprintf(stream,
"\r\n"
" -- %s --\r\n"
"\n"
"%s\r\n",
lpCaption ? lpCaption : "***", lpText);
fflush(stream);
if (prompt == NULL || buttons == NULL)
{
return IDOK;
}
UINT defbtn = (uType & MB_DEFMASK) >> 8;
if (defbtn >= strlen(buttons))
{
defbtn = 0;
}
int answer;
for (;;)
{
fprintf(stream,
"%s %c\b",
prompt, buttons[defbtn]);
fflush(stream);
answer = toupper(_fgetchar());
if (answer == '\r' || answer == '\n' || answer == 0)
{
answer = buttons[defbtn];
}
else if (strchr(buttons, answer) == NULL)
{
continue;
}
switch (answer)
{
case 'O':
return IDOK;
case 'C':
return IDCANCEL;
case 'A':
return IDABORT;
case 'R':
return IDRETRY;
case 'I':
return IDIGNORE;
case 'Y':
return IDYES;
case 'N':
return IDNO;
case 'T':
return IDTRYAGAIN;
case 'U':
return IDCONTINUE;
}
}
}