?? msgbox.c
字號:
/* * MSGBOX.C - msgbox internal command. * * clone from 4nt msgbox command * * 25 Aug 1999 * started - Paolo Pantaleo <paolopan@freemail.it> */#include "config.h"#ifdef INCLUDE_CMD_MSGBOX#include "cmd.h"#define U_TYPE_INIT 0//undefine it to allow to omit arguments//that will be replaced by default ones#define _SYNTAX_CHECKINT CommandMsgbox (LPTSTR cmd, LPTSTR param){ //used to parse command line LPTSTR tmp; //used to find window title (used as messagebox title) //and to find window handle to pass to MessageBox HWND hWnd; TCHAR buff[128]; //these are MessabeBox() parameters LPTSTR title, prompt= _T(""); UINT uType=U_TYPE_INIT; //set default title to window title GetConsoleTitle(buff,128); title = buff; if (_tcsncmp (param, _T("/?"), 2) == 0) { ConOutPuts( _T("display a message box and return user responce\n") _T("\n") _T("MSGBOX type [\"title\"] prompt\n") _T("\n") _T("type button displayed\n") _T(" possible values are: OK, OKCANCEL,\n") _T(" YESNO, YESNOCANCEL\n") _T("title title of message box\n") _T("prompt text displayed by the message box\n") _T("\n") _T("\n") _T("ERRORLEVEL is set according the button pressed:\n") _T("\n") _T("YES : 10 | NO : 11\n") _T("OK : 10 | CANCEL : 12\n")); return 0; } //yes here things are quite massed up :) //skip spaces while(_istspace(*param)) param++; //search for type of messagebox (ok, okcancel, ...) if (_tcsnicmp(param, _T("ok "),3 ) == 0) { uType |= MB_ICONEXCLAMATION | MB_OK; param+=3; } else if (_tcsnicmp(param, _T("okcancel "),9 ) == 0) { uType |= MB_ICONQUESTION | MB_OKCANCEL; param+=9; } else if (_tcsnicmp(param, _T("yesno "),6 ) == 0) { uType |= MB_ICONQUESTION | MB_YESNO; param+=6; } else if (_tcsnicmp(param, _T("yesnocancel "), 12 ) == 0) { uType |= MB_ICONQUESTION | MB_YESNOCANCEL; param+=12; } else{#ifdef _SYNTAX_CHECK error_req_param_missing (); return 1;#else uType |= MB_ICONEXCLAMATION | MB_OK;#endif } //skip spaces while(_istspace(*param)) param++;#ifdef _SYNTAX_CHECK //if reached end of string //it is an error becuase we do not yet have prompt if ( *param == 0) { error_req_param_missing (); return 1; }#endif //search for "title" tmp = param; if(*param == '"') { tmp = _tcschr(param+1,'"'); if (tmp) { *tmp = 0; title = param+1; tmp++; param = tmp; } } //skip spaces while(_istspace(*param)) param++;#ifdef _SYNTAX_CHECK //get prompt if ( *param == 0) { error_req_param_missing (); return 1; }#endif prompt = param; hWnd=GetConsoleWindow ();// DebugPrintf("FindWindow hWnd = %d\n",hWnd); ConErrPrintf(_T("FindWindow hWnd = %d\n"),hWnd); switch ( MessageBox(hWnd,prompt,title,uType) ) { case IDYES: case IDOK: nErrorLevel = 10; break; case IDNO: nErrorLevel = 11; break; case IDCANCEL: nErrorLevel = 12; break; } return 0;}#endif /* INCLUDE_CMD_MSGBOX */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -