3 * WINDOW.C - activate & window internal commands.
5 * clone from 4nt activate command
7 * 10 Sep 1999 (Paolo Pantaleo)
8 * started (window command in WINDOW.c)
10 * 29 Sep 1999 (Paolo Pantaleo)
11 * activate and window in a single file using mainly the same code
12 * (nice size optimization :)
14 * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
15 * Remove all hardcode string to En.rc
22 #if ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) )
27 #define A_RESTORE 0x04
33 /*service funciton to perform actions on windows
35 param is a string to parse for options/actions
36 hWnd is the handle of window on wich perform actions
40 static INT
ServiceActivate (LPTSTR param
, HWND hWnd
)
52 p
= split(param
, &argc
, FALSE
);
54 for (i
= 0; i
< argc
; i
++)
57 if (*p_tmp
== _T('/'))
60 if (_tcsicmp(p_tmp
, _T("min")) == 0)
66 if (_tcsicmp(p_tmp
, _T("max")) == 0)
72 if (_tcsicmp(p_tmp
, _T("restore")) == 0)
78 if (_tcsicmp(p_tmp
, _T("close")) == 0)
84 if (_tcsnicmp(p_tmp
, _T("pos"), 3) == 0)
92 if(!(tmp
=_tcschr(tmp
, _T(','))))
94 error_invalid_parameter_format(p
[i
]);
99 pos
.top
= _ttoi (++tmp
);
100 if(!(tmp
=_tcschr(tmp
, _T(','))))
102 error_invalid_parameter_format(p
[i
]);
107 pos
.right
= _ttoi(++tmp
) + pos
.left
;
108 if (!(tmp
= _tcschr(tmp
, _T(','))))
110 error_invalid_parameter_format(p
[i
]);
114 pos
.bottom
= _ttoi(++tmp
) + pos
.top
;
118 if (_tcsnicmp(p_tmp
, _T("size"), 4)==0)
124 /* none of them=window title */
127 error_invalid_parameter_format(p
[i
]);
132 if (p_tmp
[0] == _T('"'))
135 *_tcschr(p_tmp
+ 1, _T('"')) = 0;
142 SetWindowText(hWnd
, title
);
144 wp
.length
= sizeof(WINDOWPLACEMENT
);
145 GetWindowPlacement(hWnd
, &wp
);
148 wp
.rcNormalPosition
= pos
;
151 wp
.showCmd
= SW_MINIMIZE
;
154 wp
.showCmd
= SW_SHOWMAXIMIZED
;
156 /*if no actions are specified default is SW_RESTORE*/
157 if ((iAction
& A_RESTORE
) || (!iAction
))
158 wp
.showCmd
= SW_RESTORE
;
160 if (iAction
& A_CLOSE
)
163 ConErrPrintf(_T("!!!FIXME: CLOSE Not implemented!!!\n"));
167 wp
.length
= sizeof(WINDOWPLACEMENT
);
168 SetWindowPlacement(hWnd
, &wp
);
179 INT
CommandWindow (LPTSTR cmd
, LPTSTR param
)
183 if (_tcsncmp (param
, _T("/?"), 2) == 0)
185 ConOutResPaging(TRUE
,STRING_WINDOW_HELP1
);
189 hwnd
= GetConsoleWindow();
191 return ServiceActivate(param
, hwnd
);
195 INT
CommandActivate (LPTSTR cmd
, LPTSTR param
)
201 if (_tcsncmp (param
, _T("/?"), 2) == 0)
203 ConOutResPaging(TRUE
,STRING_WINDOW_HELP2
);
210 /*Split the user input into array*/
211 arg
= split (param
, &argc
, FALSE
);
217 hwnd
= FindWindow(NULL
, arg
[0]);
222 ConErrResPuts(STRING_WINDOW_ERROR1
);
228 return ServiceActivate(param
, hwnd
);
231 #endif /* ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) ) */