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) )
23 #define A_RESTORE 0x04
29 /*service funciton to perform actions on windows
31 param is a string to parse for options/actions
32 hWnd is the handle of window on wich perform actions
37 INT
ServiceActivate (LPTSTR param
, HWND hWnd
)
52 for(i
= 0; i
< argc
; i
++)
55 if (*p_tmp
== _T('/'))
58 if (_tcsicmp(p_tmp
,_T("min"))==0)
64 if (_tcsicmp(p_tmp
,_T("max"))==0)
70 if (_tcsicmp(p_tmp
,_T("restore"))==0)
76 if (_tcsicmp(p_tmp
,_T("close"))==0)
82 if (_tcsnicmp(p_tmp
,_T("pos"),3)==0)
90 if(!(tmp
=_tcschr(tmp
,_T(','))))
92 error_invalid_parameter_format(p
[i
]);
97 pos
.top
= _ttoi (++tmp
);
98 if(!(tmp
=_tcschr(tmp
,_T(','))))
100 error_invalid_parameter_format(p
[i
]);
105 pos
.right
= _ttoi(++tmp
)+pos
.left
;
106 if(!(tmp
=_tcschr(tmp
,_T(','))))
108 error_invalid_parameter_format(p
[i
]);
112 pos
.bottom
= _ttoi(++tmp
) + pos
.top
;
116 if (_tcsnicmp(p_tmp
,_T("size"),4)==0)
122 /*none of them=window title*/
125 error_invalid_parameter_format(p
[i
]);
130 if (p_tmp
[0] == _T('"'))
133 *_tcschr(p_tmp
+1,_T('"'))=0;
140 SetWindowText(hWnd
,title
);
142 wp
.length
=sizeof(WINDOWPLACEMENT
);
143 GetWindowPlacement(hWnd
,&wp
);
146 wp
.rcNormalPosition
= pos
;
149 wp
.showCmd
=SW_MINIMIZE
;
152 wp
.showCmd
=SW_SHOWMAXIMIZED
;
154 /*if no actions are specified default is SW_RESTORE*/
155 if( (iAction
& A_RESTORE
) || (!iAction
) )
156 wp
.showCmd
=SW_RESTORE
;
158 if(iAction
& A_CLOSE
)
159 ConErrPrintf(_T("!!!FIXME: CLOSE Not implemented!!!\n"));
161 wp
.length
=sizeof(WINDOWPLACEMENT
);
162 SetWindowPlacement(hWnd
,&wp
);
173 INT
CommandWindow (LPTSTR cmd
, LPTSTR param
)
177 if (_tcsncmp (param
, _T("/?"), 2) == 0)
179 ConOutPuts(_T("change console window aspect\n"
181 "WINDOW [/POS[=]left,top,width,heigth]\n"
182 " [MIN|MAX|RESTORE] [\"title\"]\n"
184 "/POS specify window placement and dimensions\n"
185 "MIN minimize the window\n"
186 "MAX maximize the window\n"
187 "RESTORE restore the window"));
191 h
= GetConsoleWindow();
193 return ServiceActivate(param
,h
);
197 INT
CommandActivate (LPTSTR cmd
, LPTSTR param
)
202 if (_tcsncmp (param
, _T("/?"), 2) == 0)
204 ConOutPuts(_T("change console window aspect\n"
206 "ACTIAVTE \"window\" [/POS[=]left,top,width,heigth]\n"
207 " [MIN|MAX|RESTORE] [\"title\"]\n"
209 "window tile of window on wich perform actions\n"
210 "/POS specify window placement and dimensions\n"
211 "MIN minimize the window\n"
212 "MAX maximize the window\n"
213 "RESTORE restore the window\n"
221 str
=_tcschr(param
,_T(' '));
231 h
=FindWindow(NULL
, param
);
234 ConErrPuts("window not found");
238 return ServiceActivate(str
,h
);
241 #endif /* ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) ) */