2 * WINDOW.C - activate & window internal commands.
4 * clone from 4nt activate command
6 * 10 Sep 1999 (Paolo Pantaleo)
7 * started (window command in WINDOW.c)
9 * 29 Sep 1999 (Paolo Pantaleo)
10 * activate and window in a single file using mainly the same code
11 * (nice size optimization :)
13 * 30-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
14 * Remove all hardcoded strings in En.rc
20 #if defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE)
25 #define A_RESTORE 0x04
32 * service function to perform actions on windows
34 * param is a string to parse for options/actions
35 * hWnd is the handle of window on which to perform actions
37 static INT
ServiceActivate (LPTSTR param
, HWND hWnd
)
48 p
= split(param
, &argc
, FALSE
);
50 for (i
= 0; i
< argc
; i
++)
53 if (*p_tmp
== _T('/'))
56 if (_tcsicmp(p_tmp
, _T("min")) == 0)
62 if (_tcsicmp(p_tmp
, _T("max")) == 0)
68 if (_tcsicmp(p_tmp
, _T("restore")) == 0)
74 if (_tcsicmp(p_tmp
, _T("close")) == 0)
80 if (_tcsnicmp(p_tmp
, _T("pos"), 3) == 0)
88 if (!(tmp
=_tcschr(tmp
, _T(','))))
90 error_invalid_parameter_format(p
[i
]);
95 pos
.top
= _ttoi (++tmp
);
96 if (!(tmp
=_tcschr(tmp
, _T(','))))
98 error_invalid_parameter_format(p
[i
]);
103 pos
.right
= _ttoi(++tmp
) + pos
.left
;
104 if (!(tmp
= _tcschr(tmp
, _T(','))))
106 error_invalid_parameter_format(p
[i
]);
110 pos
.bottom
= _ttoi(++tmp
) + pos
.top
;
114 if (_tcsnicmp(p_tmp
, _T("size"), 4)==0)
120 /* none of them=window title */
123 error_invalid_parameter_format(p
[i
]);
128 if (p_tmp
[0] == _T('"'))
131 *_tcschr(p_tmp
+ 1, _T('"')) = 0;
138 SetWindowText(hWnd
, title
);
140 wp
.length
= sizeof(WINDOWPLACEMENT
);
141 GetWindowPlacement(hWnd
, &wp
);
144 wp
.rcNormalPosition
= pos
;
147 wp
.showCmd
= SW_MINIMIZE
;
150 wp
.showCmd
= SW_SHOWMAXIMIZED
;
152 /* if no actions are specified default is SW_RESTORE */
153 if ((iAction
& A_RESTORE
) || (!iAction
))
154 wp
.showCmd
= SW_RESTORE
;
156 if (iAction
& A_CLOSE
)
158 FIXME("!!!FIXME: CLOSE Not implemented!!!\n");
161 wp
.length
= sizeof(WINDOWPLACEMENT
);
162 SetWindowPlacement(hWnd
, &wp
);
173 INT
CommandWindow (LPTSTR param
)
177 if (_tcsncmp (param
, _T("/?"), 2) == 0)
179 ConOutResPaging(TRUE
,STRING_WINDOW_HELP1
);
183 hwnd
= GetConsoleWindow();
185 return ServiceActivate(param
, hwnd
);
189 INT
CommandActivate (LPTSTR param
)
195 if (_tcsncmp (param
, _T("/?"), 2) == 0)
197 ConOutResPaging(TRUE
,STRING_WINDOW_HELP2
);
204 /* Split the user input into array */
205 arg
= split (param
, &argc
, FALSE
);
211 hwnd
= FindWindow(NULL
, arg
[0]);
216 ConErrResPuts(STRING_WINDOW_ERROR1
);
222 return ServiceActivate(param
, hwnd
);
225 #endif /* defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) */