mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 08:53:28 +00:00
Added activate command.
svn path=/trunk/; revision=684
This commit is contained in:
parent
1e637da493
commit
49f51f37f3
1 changed files with 114 additions and 45 deletions
|
@ -1,18 +1,21 @@
|
||||||
/*
|
/* $Id: window.c,v 1.3 1999/10/03 22:16:14 ekohl Exp $
|
||||||
* WINDOW.C - activate internal command.
|
|
||||||
*
|
*
|
||||||
* clone from 4nt window command
|
* WINDOW.C - activate & window internal commands.
|
||||||
*
|
*
|
||||||
* 10 Sep 1999
|
* clone from 4nt activate command
|
||||||
* started - Paolo Pantaleo <dfaustus@freemail.it>
|
|
||||||
*
|
*
|
||||||
|
* 10 Sep 1999 (Paolo Pantaleo)
|
||||||
|
* started (window command in WINDOW.c)
|
||||||
*
|
*
|
||||||
|
* 29 Sep 1999 (Paolo Pantaleo)
|
||||||
|
* activate and window in a single file using mainly the same code
|
||||||
|
* (nice size optimization :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_WINDOW
|
#if ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) )
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -26,34 +29,31 @@
|
||||||
#define A_RESTORE 0x04
|
#define A_RESTORE 0x04
|
||||||
#define A_POS 0x08
|
#define A_POS 0x08
|
||||||
#define A_SIZE 0x10
|
#define A_SIZE 0x10
|
||||||
|
#define A_CLOSE 0x20
|
||||||
|
|
||||||
|
|
||||||
INT CommandWindow (LPTSTR cmd, LPTSTR param)
|
/*service funciton to perform actions on windows
|
||||||
|
|
||||||
|
param is a string to parse for options/actions
|
||||||
|
hWnd is the handle of window on wich perform actions
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static
|
||||||
|
INT ServiceActivate (LPTSTR param, HWND hWnd)
|
||||||
{
|
{
|
||||||
LPTSTR *p,p_tmp;
|
LPTSTR *p=0,p_tmp;
|
||||||
INT argc,i;
|
INT argc=0,i;
|
||||||
INT iAction=0;
|
INT iAction=0;
|
||||||
LPTSTR title=0;
|
LPTSTR title=0;
|
||||||
HWND hWnd;
|
|
||||||
WINDOWPLACEMENT wp;
|
WINDOWPLACEMENT wp;
|
||||||
RECT pos;
|
RECT pos;
|
||||||
LPTSTR tmp;
|
LPTSTR tmp;
|
||||||
|
|
||||||
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
|
||||||
{
|
|
||||||
ConOutPuts(_T("change console window aspect\n"
|
|
||||||
"\n"
|
|
||||||
"WINDOW [/POS[=]left,top,width,heigth]\n"
|
|
||||||
" [MIN|MAX|RESTORE]\n"
|
|
||||||
"\n"
|
|
||||||
"/POS specify window placement and dimensions\n"
|
|
||||||
"MIN minimize the window\n"
|
|
||||||
"MAX maximize the window\n"
|
|
||||||
"RESTORE restore the window"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
p=split(param,&argc);
|
if(*param)
|
||||||
|
p=split(param,&argc);
|
||||||
|
|
||||||
|
|
||||||
for(i = 0; i < argc; i++)
|
for(i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,12 @@ INT CommandWindow (LPTSTR cmd, LPTSTR param)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_tcsicmp(p_tmp,_T("close"))==0)
|
||||||
|
{
|
||||||
|
iAction |= A_CLOSE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (_tcsnicmp(p_tmp,_T("pos"),3)==0)
|
if (_tcsnicmp(p_tmp,_T("pos"),3)==0)
|
||||||
{
|
{
|
||||||
iAction |= A_POS;
|
iAction |= A_POS;
|
||||||
|
@ -119,17 +125,7 @@ INT CommandWindow (LPTSTR cmd, LPTSTR param)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
/*none of them=window title*/
|
||||||
if(*p_tmp != '"')
|
|
||||||
{
|
|
||||||
error_invalid_parameter_format(p[i]);
|
|
||||||
|
|
||||||
freep(p);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//none of them=window title
|
|
||||||
if (title)
|
if (title)
|
||||||
{
|
{
|
||||||
error_invalid_parameter_format(p[i]);
|
error_invalid_parameter_format(p[i]);
|
||||||
|
@ -147,17 +143,13 @@ INT CommandWindow (LPTSTR cmd, LPTSTR param)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(title)
|
if(title)
|
||||||
SetConsoleTitle(title);
|
SetWindowText(hWnd,title);
|
||||||
|
|
||||||
hWnd=GetConsoleWindow();
|
|
||||||
|
|
||||||
wp.length=sizeof(WINDOWPLACEMENT);
|
wp.length=sizeof(WINDOWPLACEMENT);
|
||||||
GetWindowPlacement(hWnd,&wp);
|
GetWindowPlacement(hWnd,&wp);
|
||||||
|
|
||||||
if(iAction & A_POS)
|
if(iAction & A_POS)
|
||||||
{
|
wp.rcNormalPosition = pos;
|
||||||
wp.rcNormalPosition = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(iAction & A_MIN)
|
if(iAction & A_MIN)
|
||||||
wp.showCmd=SW_MINIMIZE;
|
wp.showCmd=SW_MINIMIZE;
|
||||||
|
@ -165,14 +157,91 @@ INT CommandWindow (LPTSTR cmd, LPTSTR param)
|
||||||
if(iAction & A_MAX)
|
if(iAction & A_MAX)
|
||||||
wp.showCmd=SW_SHOWMAXIMIZED;
|
wp.showCmd=SW_SHOWMAXIMIZED;
|
||||||
|
|
||||||
if(iAction & A_RESTORE)
|
/*if no actions are specified default is SW_RESTORE*/
|
||||||
|
if( (iAction & A_RESTORE) || (!iAction) )
|
||||||
wp.showCmd=SW_RESTORE;
|
wp.showCmd=SW_RESTORE;
|
||||||
|
|
||||||
|
if(iAction & A_CLOSE)
|
||||||
|
ConErrPrintf(_T("!!!FIXME: CLOSE Not implemented!!!\n"));
|
||||||
|
|
||||||
wp.length=sizeof(WINDOWPLACEMENT);
|
wp.length=sizeof(WINDOWPLACEMENT);
|
||||||
SetWindowPlacement(hWnd,&wp);
|
SetWindowPlacement(hWnd,&wp);
|
||||||
|
|
||||||
freep(p);
|
if(p)
|
||||||
|
freep(p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* INCLUDE_CMD_WINDOW */
|
|
||||||
|
|
||||||
|
|
||||||
|
INT CommandWindow (LPTSTR cmd, LPTSTR param)
|
||||||
|
{
|
||||||
|
HWND h;
|
||||||
|
|
||||||
|
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||||
|
{
|
||||||
|
ConOutPuts(_T("change console window aspect\n"
|
||||||
|
"\n"
|
||||||
|
"WINDOW [/POS[=]left,top,width,heigth]\n"
|
||||||
|
" [MIN|MAX|RESTORE] [\"title\"]\n"
|
||||||
|
"\n"
|
||||||
|
"/POS specify window placement and dimensions\n"
|
||||||
|
"MIN minimize the window\n"
|
||||||
|
"MAX maximize the window\n"
|
||||||
|
"RESTORE restore the window"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = GetConsoleWindow();
|
||||||
|
Sleep(0);
|
||||||
|
return ServiceActivate(param,h);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INT CommandActivate (LPTSTR cmd, LPTSTR param)
|
||||||
|
{
|
||||||
|
LPTSTR str;
|
||||||
|
HWND h;
|
||||||
|
|
||||||
|
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||||
|
{
|
||||||
|
ConOutPuts(_T("change console window aspect\n"
|
||||||
|
"\n"
|
||||||
|
"ACTIAVTE \"window\" [/POS[=]left,top,width,heigth]\n"
|
||||||
|
" [MIN|MAX|RESTORE] [\"title\"]\n"
|
||||||
|
"\n"
|
||||||
|
"window tile of window on wich perform actions\n"
|
||||||
|
"/POS specify window placement and dimensions\n"
|
||||||
|
"MIN minimize the window\n"
|
||||||
|
"MAX maximize the window\n"
|
||||||
|
"RESTORE restore the window\n"
|
||||||
|
"title new title"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(*param))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
str=_tcschr(param,_T(' '));
|
||||||
|
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
*str=_T('\0');
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
str = "";
|
||||||
|
|
||||||
|
h=FindWindow(NULL, param);
|
||||||
|
if (!h)
|
||||||
|
{
|
||||||
|
ConErrPuts("window not found");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ServiceActivate(str,h);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) ) */
|
Loading…
Add table
Add a link
Reference in a new issue