ReactOS 0.4.15-dev-7834-g00c4b3d
msgbox.c
Go to the documentation of this file.
1/*
2 * MSGBOX.C - msgbox internal command.
3 *
4 * clone from 4nt msgbox command
5 *
6 * 25 Aug 1999
7 * started - Paolo Pantaleo <paolopan@freemail.it>
8 *
9 * 30-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
10 * Remove all hardcoded strings in En.rc
11 */
12
13#include "precomp.h"
14
15#ifdef INCLUDE_CMD_MSGBOX
16
17
18#define U_TYPE_INIT 0
19
20//undefine it to allow to omit arguments
21//that will be replaced by default ones
22#define _SYNTAX_CHECK
23
24
26{
27 //used to parse command line
28 LPTSTR tmp;
29
30 //used to find window title (used as messagebox title)
31 //and to find window handle to pass to MessageBox
32 HWND hWnd;
33 TCHAR buff[128];
34
35 //these are MessageBox() parameters
36 LPTSTR title, prompt = "";
37 UINT uType = U_TYPE_INIT;
38
39 /* set default title to window title */
41 title = buff;
42
43 if (_tcsncmp (param, _T("/?"), 2) == 0)
44 {
46 return 0;
47 }
48
49 //yes here things are quite massed up :)
50
51 //skip spaces
52 while(_istspace(*param))
53 param++;
54
55 //search for type of messagebox (ok, okcancel, ...)
56 if (_tcsnicmp(param, _T("ok "), 3) == 0)
57 {
58 uType |= MB_ICONEXCLAMATION | MB_OK;
59 param += 3;
60 }
61 else if (_tcsnicmp(param, _T("okcancel "), 9) == 0)
62 {
64 param += 9;
65 }
66 else if (_tcsnicmp(param, _T("yesno "), 6) == 0)
67 {
68 uType |= MB_ICONQUESTION | MB_YESNO;
69 param += 6;
70 }
71 else if (_tcsnicmp(param, _T("yesnocancel "), 12) == 0)
72 {
74 param += 12;
75 }
76 else
77 {
78#ifdef _SYNTAX_CHECK
80 return 1;
81#else
82 uType |= MB_ICONEXCLAMATION | MB_OK;
83#endif
84 }
85
86 //skip spaces
87 while(_istspace(*param))
88 param++;
89
90#ifdef _SYNTAX_CHECK
91 //if reached end of string
92 //it is an error becuase we do not yet have prompt
93 if (*param == 0)
94 {
96 return 1;
97 }
98#endif
99
100 //search for "title"
101 tmp = param;
102
103 if (*param == '"')
104 {
105 tmp = _tcschr(param + 1, '"');
106 if (tmp)
107 {
108 *tmp = 0;
109 title = param + 1;
110 tmp++;
111 param = tmp;
112 }
113 }
114
115 //skip spaces
116 while(_istspace(*param))
117 param++;
118
119#ifdef _SYNTAX_CHECK
120 //get prompt
121 if (*param == 0)
122 {
124 return 1;
125 }
126#endif
127
128 prompt = param;
129
131
132 switch (MessageBox(hWnd, prompt, title, uType))
133 {
134 case IDYES:
135 case IDOK:
136 nErrorLevel = 10;
137 break;
138
139 case IDNO:
140 nErrorLevel = 11;
141 break;
142
143 case IDCANCEL:
144 nErrorLevel = 12;
145 break;
146 }
147
148 return 0;
149}
150
151#endif /* INCLUDE_CMD_MSGBOX */
152
153/* EOF */
HWND hWnd
Definition: settings.c:17
INT nErrorLevel
Definition: cmd.c:158
INT CommandMsgbox(LPTSTR)
VOID error_req_param_missing(VOID)
Definition: error.c:110
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:182
#define STRING_MSGBOX_HELP
Definition: resource.h:149
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow(VOID)
Definition: console.c:2729
static unsigned char buff[32768]
Definition: fatten.c:17
GLfloat param
Definition: glext.h:5796
#define _istspace
Definition: tchar.h:1504
#define _tcsncmp
Definition: tchar.h:1428
#define _tcschr
Definition: tchar.h:1406
unsigned int UINT
Definition: ndis.h:50
static char title[]
Definition: ps.c:92
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
#define GetConsoleTitle
Definition: wincon.h:775
#define IDCANCEL
Definition: winuser.h:831
#define MB_YESNO
Definition: winuser.h:817
#define IDOK
Definition: winuser.h:830
#define MB_OKCANCEL
Definition: winuser.h:804
#define IDNO
Definition: winuser.h:836
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_OK
Definition: winuser.h:790
#define MB_ICONQUESTION
Definition: winuser.h:789
#define MessageBox
Definition: winuser.h:5822
#define IDYES
Definition: winuser.h:835
#define MB_YESNOCANCEL
Definition: winuser.h:818
char TCHAR
Definition: xmlstorage.h:189
#define _tcsnicmp
Definition: xmlstorage.h:207
CHAR * LPTSTR
Definition: xmlstorage.h:192