1 /* $Id: window.c,v 1.3 1999/10/03 22:16:14 ekohl Exp $
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 :)
18 #if ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) )
29 #define A_RESTORE 0x04
35 /*service funciton to perform actions on windows
37 param is a string to parse for options/actions
38 hWnd is the handle of window on wich perform actions
43 INT
ServiceActivate (LPTSTR param
, HWND hWnd
)
58 for(i
= 0; i
< argc
; i
++)
61 if (*p_tmp
== _T('/'))
64 if (_tcsicmp(p_tmp
,_T("min"))==0)
70 if (_tcsicmp(p_tmp
,_T("max"))==0)
76 if (_tcsicmp(p_tmp
,_T("restore"))==0)
82 if (_tcsicmp(p_tmp
,_T("close"))==0)
88 if (_tcsnicmp(p_tmp
,_T("pos"),3)==0)
96 if(!(tmp
=_tcschr(tmp
,_T(','))))
98 error_invalid_parameter_format(p
[i
]);
103 pos
.top
= _ttoi (++tmp
);
104 if(!(tmp
=_tcschr(tmp
,_T(','))))
106 error_invalid_parameter_format(p
[i
]);
111 pos
.right
= _ttoi(++tmp
)+pos
.left
;
112 if(!(tmp
=_tcschr(tmp
,_T(','))))
114 error_invalid_parameter_format(p
[i
]);
118 pos
.bottom
= _ttoi(++tmp
) + pos
.top
;
122 if (_tcsnicmp(p_tmp
,_T("size"),4)==0)
128 /*none of them=window title*/
131 error_invalid_parameter_format(p
[i
]);
136 if (p_tmp
[0] == _T('"'))
139 *_tcschr(p_tmp
+1,_T('"'))=0;
146 SetWindowText(hWnd
,title
);
148 wp
.length
=sizeof(WINDOWPLACEMENT
);
149 GetWindowPlacement(hWnd
,&wp
);
152 wp
.rcNormalPosition
= pos
;
155 wp
.showCmd
=SW_MINIMIZE
;
158 wp
.showCmd
=SW_SHOWMAXIMIZED
;
160 /*if no actions are specified default is SW_RESTORE*/
161 if( (iAction
& A_RESTORE
) || (!iAction
) )
162 wp
.showCmd
=SW_RESTORE
;
164 if(iAction
& A_CLOSE
)
165 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 ConOutPuts(_T("change console window aspect\n"
187 "WINDOW [/POS[=]left,top,width,heigth]\n"
188 " [MIN|MAX|RESTORE] [\"title\"]\n"
190 "/POS specify window placement and dimensions\n"
191 "MIN minimize the window\n"
192 "MAX maximize the window\n"
193 "RESTORE restore the window"));
197 h
= GetConsoleWindow();
199 return ServiceActivate(param
,h
);
203 INT
CommandActivate (LPTSTR cmd
, LPTSTR param
)
208 if (_tcsncmp (param
, _T("/?"), 2) == 0)
210 ConOutPuts(_T("change console window aspect\n"
212 "ACTIAVTE \"window\" [/POS[=]left,top,width,heigth]\n"
213 " [MIN|MAX|RESTORE] [\"title\"]\n"
215 "window tile of window on wich perform actions\n"
216 "/POS specify window placement and dimensions\n"
217 "MIN minimize the window\n"
218 "MAX maximize the window\n"
219 "RESTORE restore the window\n"
227 str
=_tcschr(param
,_T(' '));
237 h
=FindWindow(NULL
, param
);
240 ConErrPuts("window not found");
244 return ServiceActivate(str
,h
);
247 #endif /* ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) ) */