2 * MSGBOX.C - msgbox internal command.
4 * clone from 4nt msgbox command
7 * started - Paolo Pantaleo <paolopan@freemail.it>
9 * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
10 * Remove all hardcode string to En.rc
16 #ifdef INCLUDE_CMD_MSGBOX
21 //undefine it to allow to omit arguments
22 //that will be replaced by default ones
26 INT
CommandMsgbox (LPTSTR cmd
, LPTSTR param
)
29 //used to parse command line
32 //used to find window title (used as messagebox title)
33 //and to find window handle to pass to MessageBox
37 //these are MessabeBox() parameters
38 LPTSTR title
, prompt
= "";
39 UINT uType
= U_TYPE_INIT
;
41 /* set default title to window title */
42 GetConsoleTitle(buff
, 128);
45 if (_tcsncmp (param
, _T("/?"), 2) == 0)
47 ConOutResPuts(STRING_MSGBOX_HELP
);
51 //yes here things are quite massed up :)
54 while(_istspace(*param
))
57 //search for type of messagebox (ok, okcancel, ...)
58 if (_tcsnicmp(param
, _T("ok "), 3) == 0)
60 uType
|= MB_ICONEXCLAMATION
| MB_OK
;
63 else if (_tcsnicmp(param
, _T("okcancel "), 9) == 0)
65 uType
|= MB_ICONQUESTION
| MB_OKCANCEL
;
68 else if (_tcsnicmp(param
, _T("yesno "), 6) == 0)
70 uType
|= MB_ICONQUESTION
| MB_YESNO
;
73 else if (_tcsnicmp(param
, _T("yesnocancel "), 12) == 0)
75 uType
|= MB_ICONQUESTION
| MB_YESNOCANCEL
;
81 error_req_param_missing ();
84 uType
|= MB_ICONEXCLAMATION
| MB_OK
;
90 while(_istspace(*param
))
94 //if reached end of string
95 //it is an error becuase we do not yet have prompt
98 error_req_param_missing ();
108 tmp
= _tcschr(param
+ 1, '"');
119 while(_istspace(*param
))
126 error_req_param_missing ();
133 hWnd
=GetConsoleWindow ();
134 // DebugPrintf("FindWindow hWnd = %d\n",hWnd);
135 // ConErrPrintf("FindWindow hWnd = %d\n",hWnd);
137 switch (MessageBox(hWnd
, prompt
, title
, uType
))
156 #endif /* INCLUDE_CMD_MSGBOX */