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

window.c
Go to the documentation of this file.
00001 /* $Id: window.c 35647 2008-08-25 23:22:03Z jmorlan $
00002  *
00003  * WINDOW.C - activate & window internal commands.
00004  *
00005  * clone from 4nt activate command
00006  *
00007  * 10 Sep 1999 (Paolo Pantaleo)
00008  *     started (window command in WINDOW.c)
00009  *
00010  * 29 Sep 1999 (Paolo Pantaleo)
00011  *     activate and window in a single file using mainly the same code
00012  *     (nice size optimization :)
00013  *
00014  *    30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
00015  *        Remove all hardcode string to En.rc
00016  */
00017 
00018 
00019 #include <precomp.h>
00020 
00021 #if (  defined(INCLUDE_CMD_WINDOW) ||  defined(INCLUDE_CMD_ACTIVATE)  )
00022 
00023 
00024 #define A_MIN       0x01
00025 #define A_MAX       0x02
00026 #define A_RESTORE   0x04
00027 #define A_POS       0x08
00028 #define A_SIZE      0x10
00029 #define A_CLOSE     0x20
00030 
00031 
00032 /*service funciton to perform actions on windows
00033 
00034  param is a string to parse for options/actions
00035  hWnd is the handle of window on wich perform actions
00036 
00037 */
00038 
00039 static INT ServiceActivate (LPTSTR param, HWND hWnd)
00040 {
00041     LPTSTR *p = 0, p_tmp;
00042     INT argc = 0, i;
00043     INT iAction = 0;
00044     LPTSTR title = 0;
00045     WINDOWPLACEMENT wp;
00046     RECT pos;
00047     LPTSTR tmp;
00048 
00049 
00050     if (*param)
00051         p = split(param, &argc, FALSE);
00052 
00053     for (i = 0; i < argc; i++)
00054     {
00055         p_tmp = p[i];
00056         if (*p_tmp == _T('/'))
00057             p_tmp++;
00058 
00059         if (_tcsicmp(p_tmp, _T("min")) == 0)
00060         {
00061             iAction |= A_MIN;
00062             continue;
00063         }
00064 
00065         if (_tcsicmp(p_tmp, _T("max")) == 0)
00066         {
00067             iAction |= A_MAX;
00068             continue;
00069         }
00070 
00071         if (_tcsicmp(p_tmp, _T("restore")) == 0)
00072         {
00073             iAction |= A_RESTORE;
00074             continue;
00075         }
00076 
00077         if (_tcsicmp(p_tmp, _T("close")) == 0)
00078         {
00079             iAction |= A_CLOSE;
00080             continue;
00081         }
00082 
00083         if (_tcsnicmp(p_tmp, _T("pos"), 3) == 0)
00084         {
00085             iAction |= A_POS;
00086             tmp = p_tmp+3;
00087             if (*tmp == _T('='))
00088                 tmp++;
00089 
00090             pos.left= _ttoi(tmp);
00091             if(!(tmp=_tcschr(tmp, _T(','))))
00092             {
00093                 error_invalid_parameter_format(p[i]);
00094                 freep(p);
00095                 return 1;
00096             }
00097 
00098             pos.top = _ttoi (++tmp);
00099             if(!(tmp=_tcschr(tmp, _T(','))))
00100             {
00101                 error_invalid_parameter_format(p[i]);
00102                 freep(p);
00103                 return 1;
00104             }
00105 
00106             pos.right = _ttoi(++tmp) + pos.left;
00107             if (!(tmp = _tcschr(tmp, _T(','))))
00108             {
00109                 error_invalid_parameter_format(p[i]);
00110                 freep(p);
00111                 return 1;
00112             }
00113             pos.bottom = _ttoi(++tmp) + pos.top;
00114             continue;
00115         }
00116 
00117         if (_tcsnicmp(p_tmp, _T("size"), 4)==0)
00118         {
00119             iAction |=A_SIZE;
00120             continue;
00121         }
00122 
00123         /* none of them=window title */
00124         if (title)
00125         {
00126             error_invalid_parameter_format(p[i]);
00127             freep(p);
00128             return 1;
00129         }
00130 
00131         if (p_tmp[0] == _T('"'))
00132         {
00133             title = (p_tmp + 1);
00134             *_tcschr(p_tmp + 1, _T('"')) = 0;
00135             continue;
00136         }
00137         title = p_tmp;
00138     }
00139 
00140     if (title)
00141         SetWindowText(hWnd, title);
00142 
00143     wp.length = sizeof(WINDOWPLACEMENT);
00144     GetWindowPlacement(hWnd, &wp);
00145 
00146     if (iAction & A_POS)
00147         wp.rcNormalPosition = pos;
00148 
00149     if (iAction & A_MIN)
00150         wp.showCmd = SW_MINIMIZE;
00151 
00152     if (iAction & A_MAX)
00153         wp.showCmd = SW_SHOWMAXIMIZED;
00154 
00155     /*if no actions are specified default is SW_RESTORE*/
00156     if ((iAction & A_RESTORE) || (!iAction))
00157         wp.showCmd = SW_RESTORE;
00158 
00159     if (iAction & A_CLOSE)
00160     {
00161         FIXME("!!!FIXME:  CLOSE Not implemented!!!\n");
00162     }
00163 
00164     wp.length = sizeof(WINDOWPLACEMENT);
00165     SetWindowPlacement(hWnd, &wp);
00166 
00167     if (p)
00168         freep(p);
00169 
00170     return 0;
00171 }
00172 
00173 
00174 
00175 
00176 INT CommandWindow (LPTSTR param)
00177 {
00178     HWND hwnd;
00179 
00180     if (_tcsncmp (param, _T("/?"), 2) == 0)
00181     {
00182     ConOutResPaging(TRUE,STRING_WINDOW_HELP1);
00183         return 0;
00184     }
00185 
00186     hwnd = GetConsoleWindow();
00187     Sleep(0);
00188     return ServiceActivate(param, hwnd);
00189 }
00190 
00191 
00192 INT CommandActivate (LPTSTR param)
00193 {
00194     HWND hwnd;
00195     LPTSTR *arg;
00196     INT argc;
00197 
00198     if (_tcsncmp (param, _T("/?"), 2) == 0)
00199     {
00200         ConOutResPaging(TRUE,STRING_WINDOW_HELP2);
00201         return 0;
00202     }
00203 
00204     if(!(*param))
00205         return 1;
00206 
00207     /*Split the user input into array*/
00208     arg = split (param, &argc, FALSE);
00209     if(argc < 2)
00210     {
00211         if(arg != NULL)
00212             freep(arg);
00213     }
00214     hwnd = FindWindow(NULL, arg[0]);
00215     if (hwnd == NULL)
00216     {
00217         if(arg != NULL)
00218             freep(arg);
00219         ConErrResPuts(STRING_WINDOW_ERROR1);
00220         return 1;
00221     }
00222     if(arg != NULL)
00223         freep(arg);
00224 
00225     return ServiceActivate(param, hwnd);
00226 }
00227 
00228 #endif /* (  defined(INCLUDE_CMD_WINDOW) ||  defined(INCLUDE_CMD_ACTIVATE)  ) */

Generated on Sun May 27 2012 04:18:17 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.