254b699be0eb887d0f6a0cf29ba35cf424ec089c
2 * WINDOW.C - activate internal command.
4 * clone from 4nt window command
7 * started - Paolo Pantaleo <dfaustus@freemail.it>
15 #ifdef INCLUDE_CMD_WINDOW
26 #define A_RESTORE 0x04
31 INT
CommandWindow (LPTSTR cmd
, LPTSTR param
)
42 if (_tcsncmp (param
, _T("/?"), 2) == 0)
44 ConOutPuts(_T("change console window aspect\n"
46 "WINDOW [/POS[=]left,top,width,heigth]\n"
47 " [MIN|MAX|RESTORE]\n"
49 "/POS specify window placement and dimensions\n"
50 "MIN minimize the window\n"
51 "MAX maximize the window\n"
52 "RESTORE restore the window"));
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 (_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)
125 error_invalid_parameter_format(p
[i
]);
132 //none of them=window title
135 error_invalid_parameter_format(p
[i
]);
140 if (p_tmp
[0] == _T('"'))
143 *_tcschr(p_tmp
+1,_T('"'))=0;
150 SetConsoleTitle(title
);
152 hWnd
=GetConsoleWindow();
154 wp
.length
=sizeof(WINDOWPLACEMENT
);
155 GetWindowPlacement(hWnd
,&wp
);
159 wp
.rcNormalPosition
= pos
;
163 wp
.showCmd
=SW_MINIMIZE
;
166 wp
.showCmd
=SW_SHOWMAXIMIZED
;
168 if(iAction
& A_RESTORE
)
169 wp
.showCmd
=SW_RESTORE
;
171 wp
.length
=sizeof(WINDOWPLACEMENT
);
172 SetWindowPlacement(hWnd
,&wp
);
178 #endif /* INCLUDE_CMD_WINDOW */