2 * MSGBOX.C - msgbox internal command.
4 * clone from 4nt msgbox command
7 * started - Paolo Pantaleo <paolopan@freemail.it>
12 #ifdef INCLUDE_CMD_MSGBOX
25 //undefine it to allow to omit arguments
26 //that will be replaced by default ones
30 INT
CommandMsgbox (LPTSTR cmd
, LPTSTR param
)
32 //used to parse command line
35 //used to find window title (used as messagebox title)
36 //and to find window handle to pass to MessageBox
40 //these are MessabeBox() parameters
41 LPTSTR title
, prompt
="";
42 UINT uType
=U_TYPE_INIT
;
44 //set default title to window title
45 GetConsoleTitle(buff
,128);
48 if (_tcsncmp (param
, _T("/?"), 2) == 0)
51 "display a message box and return user responce\n"
53 "MSGBOX type [\"title\"] prompt\n"
55 "type button displayed\n"
56 " possible values are: OK, OKCANCEL,\n"
57 " YESNO, YESNOCANCEL\n"
58 "title title of message box\n"
59 "prompt text displayed by the message box\n"
62 "ERRORLEVEL is set according the button pressed:\n"
64 "YES : 10 | NO : 11\n"
65 "OK : 10 | CANCEL : 12\n"));
69 //yes here things are quite massed up :)
72 while(_istspace(*param
))
75 //search for type of messagebox (ok, okcancel, ...)
76 if (_tcsnicmp(param
, _T("ok "),3 ) == 0)
78 uType
|= MB_ICONEXCLAMATION
| MB_OK
;
81 else if (_tcsnicmp(param
, _T("okcancel "),9 ) == 0)
83 uType
|= MB_ICONQUESTION
| MB_OKCANCEL
;
86 else if (_tcsnicmp(param
, _T("yesno "),6 ) == 0)
88 uType
|= MB_ICONQUESTION
| MB_YESNO
;
91 else if (_tcsnicmp(param
, _T("yesnocancel "), 12 ) == 0)
93 uType
|= MB_ICONQUESTION
| MB_YESNOCANCEL
;
98 error_req_param_missing ();
101 uType
|= MB_ICONEXCLAMATION
| MB_OK
;
107 while(_istspace(*param
))
111 //if reached end of string
112 //it is an error becuase we do not yet have prompt
115 error_req_param_missing ();
125 tmp
= _tcschr(param
+1,'"');
136 while(_istspace(*param
))
142 error_req_param_missing ();
149 hWnd
=GetConsoleWindow ();
150 // DebugPrintf("FindWindow hWnd = %d\n",hWnd);
151 ConErrPrintf("FindWindow hWnd = %d\n",hWnd
);
154 MessageBox(hWnd
,prompt
,title
,uType
)
174 #endif /* INCLUDE_CMD_MSGBOX */