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
21 #if ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) )
26 #define A_RESTORE 0x04
32 /*service funciton to perform actions on windows
34 param is a string to parse for options/actions
35 hWnd is the handle of window on wich perform actions
39 static INT
ServiceActivate (LPTSTR param
, HWND hWnd
)
51 p
= split(param
, &argc
, FALSE
);
53 for (i
= 0; i
< argc
; i
++)
56 if (*p_tmp
== _T('/'))
59 if (_tcsicmp(p_tmp
, _T("min")) == 0)
65 if (_tcsicmp(p_tmp
, _T("max")) == 0)
71 if (_tcsicmp(p_tmp
, _T("restore")) == 0)
77 if (_tcsicmp(p_tmp
, _T("close")) == 0)
83 if (_tcsnicmp(p_tmp
, _T("pos"), 3) == 0)
91 if(!(tmp
=_tcschr(tmp
, _T(','))))
93 error_invalid_parameter_format(p
[i
]);
98 pos
.top
= _ttoi (++tmp
);
99 if(!(tmp
=_tcschr(tmp
, _T(','))))
101 error_invalid_parameter_format(p
[i
]);
106 pos
.right
= _ttoi(++tmp
) + pos
.left
;
107 if (!(tmp
= _tcschr(tmp
, _T(','))))
109 error_invalid_parameter_format(p
[i
]);
113 pos
.bottom
= _ttoi(++tmp
) + pos
.top
;
117 if (_tcsnicmp(p_tmp
, _T("size"), 4)==0)
123 /* none of them=window title */
126 error_invalid_parameter_format(p
[i
]);
131 if (p_tmp
[0] == _T('"'))
134 *_tcschr(p_tmp
+ 1, _T('"')) = 0;
141 SetWindowText(hWnd
, title
);
143 wp
.length
= sizeof(WINDOWPLACEMENT
);
144 GetWindowPlacement(hWnd
, &wp
);
147 wp
.rcNormalPosition
= pos
;
150 wp
.showCmd
= SW_MINIMIZE
;
153 wp
.showCmd
= SW_SHOWMAXIMIZED
;
155 /*if no actions are specified default is SW_RESTORE*/
156 if ((iAction
& A_RESTORE
) || (!iAction
))
157 wp
.showCmd
= SW_RESTORE
;
159 if (iAction
& A_CLOSE
)
161 FIXME("!!!FIXME: CLOSE Not implemented!!!\n");
164 wp
.length
= sizeof(WINDOWPLACEMENT
);
165 SetWindowPlacement(hWnd
, &wp
);
176 INT
CommandWindow (LPTSTR param
)
180 if (_tcsncmp (param
, _T("/?"), 2) == 0)
182 ConOutResPaging(TRUE
,STRING_WINDOW_HELP1
);
186 hwnd
= GetConsoleWindow();
188 return ServiceActivate(param
, hwnd
);
192 INT
CommandActivate (LPTSTR param
)
198 if (_tcsncmp (param
, _T("/?"), 2) == 0)
200 ConOutResPaging(TRUE
,STRING_WINDOW_HELP2
);
207 /*Split the user input into array*/
208 arg
= split (param
, &argc
, FALSE
);
214 hwnd
= FindWindow(NULL
, arg
[0]);
219 ConErrResPuts(STRING_WINDOW_ERROR1
);
225 return ServiceActivate(param
, hwnd
);
228 #endif /* ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) ) */