ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

msgbox.c
Go to the documentation of this file.
00001 /*
00002  * MSGBOX.C - msgbox internal command.
00003  *
00004  * clone from 4nt msgbox command
00005  *
00006  * 25 Aug 1999
00007  *     started - Paolo Pantaleo <paolopan@freemail.it>
00008  *
00009  *    30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
00010  *        Remove all hardcode string to En.rc
00011  */
00012 
00013 #include <precomp.h>
00014 
00015 #ifdef INCLUDE_CMD_MSGBOX
00016 
00017 
00018 #define U_TYPE_INIT 0
00019 
00020 //undefine it to allow to omit arguments
00021 //that will be replaced by default ones
00022 #define _SYNTAX_CHECK
00023 
00024 
00025 INT CommandMsgbox (LPTSTR param)
00026 {
00027 
00028     //used to parse command line
00029     LPTSTR tmp;
00030 
00031     //used to find window title (used as messagebox title)
00032     //and to find window handle to pass to MessageBox
00033     HWND hWnd;
00034     TCHAR buff[128];
00035 
00036     //these are MessabeBox() parameters
00037     LPTSTR title, prompt = "";
00038     UINT uType = U_TYPE_INIT;
00039 
00040     /* set default title to window title */
00041     GetConsoleTitle(buff, 128);
00042     title = buff;
00043 
00044     if (_tcsncmp (param, _T("/?"), 2) == 0)
00045     {
00046         ConOutResPaging(TRUE,STRING_MSGBOX_HELP);
00047         return 0;
00048     }
00049 
00050     //yes here things are quite massed up :)
00051 
00052     //skip spaces
00053     while(_istspace(*param))
00054         param++;
00055 
00056     //search for type of messagebox (ok, okcancel, ...)
00057     if (_tcsnicmp(param, _T("ok "), 3) == 0)
00058     {
00059         uType |= MB_ICONEXCLAMATION | MB_OK;
00060         param += 3;
00061     }
00062     else if (_tcsnicmp(param, _T("okcancel "), 9) == 0)
00063     {
00064         uType |= MB_ICONQUESTION | MB_OKCANCEL;
00065         param += 9;
00066     }
00067     else if (_tcsnicmp(param, _T("yesno "), 6) == 0)
00068     {
00069         uType |= MB_ICONQUESTION | MB_YESNO;
00070         param += 6;
00071     }
00072     else if (_tcsnicmp(param, _T("yesnocancel "), 12) == 0)
00073     {
00074         uType |= MB_ICONQUESTION | MB_YESNOCANCEL;
00075         param += 12;
00076     }
00077     else
00078     {
00079 #ifdef _SYNTAX_CHECK
00080         error_req_param_missing ();
00081         return 1;
00082 #else
00083         uType |= MB_ICONEXCLAMATION | MB_OK;
00084 #endif
00085     }
00086 
00087 
00088     //skip spaces
00089     while(_istspace(*param))
00090         param++;
00091 
00092 #ifdef _SYNTAX_CHECK
00093     //if reached end of string
00094     //it is an error becuase we do not yet have prompt
00095     if (*param == 0)
00096     {
00097         error_req_param_missing ();
00098         return 1;
00099     }
00100 #endif
00101 
00102     //search for "title"
00103     tmp = param;
00104 
00105     if (*param == '"')
00106     {
00107         tmp = _tcschr(param + 1, '"');
00108         if (tmp)
00109         {
00110             *tmp = 0;
00111             title = param + 1;
00112             tmp++;
00113             param = tmp;
00114         }
00115     }
00116 
00117     //skip spaces
00118     while(_istspace(*param))
00119         param++;
00120 
00121 #ifdef _SYNTAX_CHECK
00122     //get prompt
00123     if (*param == 0)
00124     {
00125         error_req_param_missing ();
00126         return 1;
00127     }
00128 #endif
00129 
00130     prompt = param;
00131 
00132     hWnd=GetConsoleWindow ();
00133 
00134     switch (MessageBox(hWnd, prompt, title, uType))
00135     {
00136         case IDYES:
00137         case IDOK:
00138             nErrorLevel = 10;
00139             break;
00140 
00141         case IDNO:
00142             nErrorLevel = 11;
00143             break;
00144 
00145         case IDCANCEL:
00146             nErrorLevel = 12;
00147             break;
00148     }
00149 
00150     return 0;
00151 }
00152 
00153 #endif /* INCLUDE_CMD_MSGBOX */
00154 
00155 /* EOF */

Generated on Mon May 28 2012 04:18:02 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.