mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 21:43:09 +00:00
Added window command.
svn path=/trunk/; revision=669
This commit is contained in:
parent
58eedf7620
commit
ee3dc0f0c1
7 changed files with 226 additions and 28 deletions
|
@ -287,6 +287,9 @@ BOOL IsValidPathName (LPCTSTR);
|
||||||
BOOL IsValidFileName (LPCTSTR);
|
BOOL IsValidFileName (LPCTSTR);
|
||||||
BOOL IsValidDirectory (LPCTSTR);
|
BOOL IsValidDirectory (LPCTSTR);
|
||||||
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
HWND GetConsoleWindow(VOID);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for MOVE.C */
|
/* Prototypes for MOVE.C */
|
||||||
|
@ -363,7 +366,8 @@ INT cmd_vol (LPTSTR, LPTSTR);
|
||||||
/* Prototypes for WHERE.C */
|
/* Prototypes for WHERE.C */
|
||||||
BOOL SearchForExecutable (LPCTSTR, LPTSTR);
|
BOOL SearchForExecutable (LPCTSTR, LPTSTR);
|
||||||
|
|
||||||
|
/* Prototypes for WINDOW.C */
|
||||||
|
INT CommandWindow (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
|
/* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
|
||||||
|
|
|
@ -217,6 +217,10 @@ COMMAND cmds[] =
|
||||||
{_T("vol"), 0, cmd_vol},
|
{_T("vol"), 0, cmd_vol},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_WINDOW
|
||||||
|
{_T("window"), 0, CommandWindow},
|
||||||
|
#endif
|
||||||
|
|
||||||
{NULL, 0, NULL}
|
{NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,9 @@
|
||||||
#define INCLUDE_CMD_BEEP
|
#define INCLUDE_CMD_BEEP
|
||||||
#define INCLUDE_CMD_VERIFY
|
#define INCLUDE_CMD_VERIFY
|
||||||
#define INCLUDE_CMD_VOL
|
#define INCLUDE_CMD_VOL
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
#define INCLUDE_CMD_WINDOW
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
commands that do not have a define:
|
commands that do not have a define:
|
||||||
|
|
|
@ -12,7 +12,7 @@ OBJECTS = cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o choice.o \
|
||||||
goto.o history.o if.o internal.o label.o locale.o memory.o misc.o \
|
goto.o history.o if.o internal.o label.o locale.o memory.o misc.o \
|
||||||
move.o msgbox.o path.o pause.o prompt.o redir.o ren.o screen.o \
|
move.o msgbox.o path.o pause.o prompt.o redir.o ren.o screen.o \
|
||||||
set.o shift.o start.o time.o timer.o title.o type.o ver.o \
|
set.o shift.o start.o time.o timer.o title.o type.o ver.o \
|
||||||
verify.o vol.o where.o cmd.coff
|
verify.o vol.o where.o window.o cmd.coff
|
||||||
|
|
||||||
CLEAN_FILES = *.o cmd.exe cmd.sym cmd.coff
|
CLEAN_FILES = *.o cmd.exe cmd.sym cmd.coff
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ $(TARGET:%=../$(DIST_DIR)/apps/%): ../$(DIST_DIR)/apps/%: %
|
||||||
ifeq ($(DOSCLI),yes)
|
ifeq ($(DOSCLI),yes)
|
||||||
$(CP) $* ..\$(DIST_DIR)\apps\$*
|
$(CP) $* ..\$(DIST_DIR)\apps\$*
|
||||||
else
|
else
|
||||||
$(CP) $* ../$(DIST_DIR)/apps/$*
|
$(CP) $* ../$(DIST_DIR)/apps\$*
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include ../rules.mak
|
include ../rules.mak
|
||||||
|
|
|
@ -295,3 +295,32 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
/*
|
||||||
|
* GetConsoleWindow - returns the handle to the current console window
|
||||||
|
*/
|
||||||
|
HWND GetConsoleWindow(VOID)
|
||||||
|
{
|
||||||
|
TCHAR original[256]; /* stores original title*/
|
||||||
|
TCHAR temp[256]; /* stores temp title*/
|
||||||
|
|
||||||
|
HWND h=0;
|
||||||
|
|
||||||
|
GetConsoleTitle(original,sizeof(original));
|
||||||
|
|
||||||
|
_tcscpy(temp,original);
|
||||||
|
_tcscat(temp,_T("-xxx "));
|
||||||
|
|
||||||
|
if((h = FindWindow("tty",temp)) == NULL )
|
||||||
|
{
|
||||||
|
SetConsoleTitle(temp);
|
||||||
|
h=FindWindow("tty",temp);
|
||||||
|
SetConsoleTitle(original);
|
||||||
|
}
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -27,30 +27,6 @@
|
||||||
#define _SYNTAX_CHECK
|
#define _SYNTAX_CHECK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HWND GetConsoleWindow(VOID)
|
|
||||||
{
|
|
||||||
TCHAR original[256]; /*holds original title*/
|
|
||||||
TCHAR temp[256]; /*holds temp title*/
|
|
||||||
|
|
||||||
HWND h=0;
|
|
||||||
|
|
||||||
GetConsoleTitle(original,sizeof(original));
|
|
||||||
|
|
||||||
_tcscpy(temp,original);
|
|
||||||
_tcscat(temp,_T("-xxx "));
|
|
||||||
|
|
||||||
if( FindWindow(0,temp) == NULL )
|
|
||||||
{
|
|
||||||
SetConsoleTitle(temp);
|
|
||||||
h=FindWindow(0,temp);
|
|
||||||
SetConsoleTitle(original);
|
|
||||||
}
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
INT CommandMsgbox (LPTSTR cmd, LPTSTR param)
|
INT CommandMsgbox (LPTSTR cmd, LPTSTR param)
|
||||||
{
|
{
|
||||||
//used to parse command line
|
//used to parse command line
|
||||||
|
@ -171,7 +147,8 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param)
|
||||||
prompt = param;
|
prompt = param;
|
||||||
|
|
||||||
hWnd=GetConsoleWindow ();
|
hWnd=GetConsoleWindow ();
|
||||||
//DebugPrintf("FindWindow hWnd = %d\n",hWnd);
|
// DebugPrintf("FindWindow hWnd = %d\n",hWnd);
|
||||||
|
ConErrPrintf("FindWindow hWnd = %d\n",hWnd);
|
||||||
|
|
||||||
switch (
|
switch (
|
||||||
MessageBox(hWnd,prompt,title,uType)
|
MessageBox(hWnd,prompt,title,uType)
|
||||||
|
|
181
rosapps/cmd/window.c
Normal file
181
rosapps/cmd/window.c
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
/*
|
||||||
|
* WINDOW.C - internal command.
|
||||||
|
*
|
||||||
|
* clone from 4nt window command
|
||||||
|
*
|
||||||
|
* 10 Sep 1999
|
||||||
|
* started - Dr.F <dfaustus@freemail.it>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_WINDOW
|
||||||
|
|
||||||
|
#include "cmd.h"
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define A_MIN 0x01
|
||||||
|
#define A_MAX 0x02
|
||||||
|
#define A_RESTORE 0x04
|
||||||
|
#define A_POS 0x08
|
||||||
|
#define A_SIZE 0x10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INT CommandWindow (LPTSTR cmd, LPTSTR param)
|
||||||
|
{
|
||||||
|
LPTSTR *p;
|
||||||
|
INT argc,i;
|
||||||
|
|
||||||
|
INT iAction=0;
|
||||||
|
|
||||||
|
LPTSTR title=0;
|
||||||
|
|
||||||
|
HWND hWnd;
|
||||||
|
WINDOWPLACEMENT wp;
|
||||||
|
RECT pos;
|
||||||
|
|
||||||
|
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 winodw\n"
|
||||||
|
"MAX maximize the winodw\n"
|
||||||
|
"RESTORE restore the window"
|
||||||
|
));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p=split(param,&argc);
|
||||||
|
|
||||||
|
for(i=0;i <argc;i++)
|
||||||
|
{
|
||||||
|
if (_tcsicmp(p[i],_T("min"))==0)
|
||||||
|
{
|
||||||
|
iAction |=A_MIN;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_tcsicmp(p[i],_T("max"))==0)
|
||||||
|
{
|
||||||
|
iAction |=A_MAX;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_tcsicmp(p[i],_T("restore"))==0)
|
||||||
|
{
|
||||||
|
iAction |=A_RESTORE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_tcsnicmp(p[i],_T("/pos"),4)==0)
|
||||||
|
{
|
||||||
|
iAction |=A_POS;
|
||||||
|
tmp = p[i]+4;
|
||||||
|
if (*tmp == _T('='))
|
||||||
|
tmp++;
|
||||||
|
|
||||||
|
pos.left=_ttoi(tmp);
|
||||||
|
if(!(tmp=_tcschr(tmp,_T(','))))
|
||||||
|
{
|
||||||
|
error_invalid_parameter_format(p[i]);
|
||||||
|
freep(p);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos.top=_ttoi(++tmp);
|
||||||
|
if(!(tmp=_tcschr(tmp,_T(','))))
|
||||||
|
{
|
||||||
|
error_invalid_parameter_format(p[i]);
|
||||||
|
freep(p);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos.right=_ttoi(++tmp)+pos.left;
|
||||||
|
if(!(tmp=_tcschr(tmp,_T(','))))
|
||||||
|
{
|
||||||
|
error_invalid_parameter_format(p[i]);
|
||||||
|
freep(p);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
pos.bottom=_ttoi(++tmp)+pos.top;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_tcsnicmp(p[i],_T("/size"),5)==0)
|
||||||
|
{
|
||||||
|
iAction |=A_SIZE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if(*p[i] != _T('"'))
|
||||||
|
{
|
||||||
|
error_invalid_parameter_format(p[i]);
|
||||||
|
|
||||||
|
freep(p);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//none of them=window title
|
||||||
|
if (title)
|
||||||
|
{
|
||||||
|
error_invalid_parameter_format(p[i]);
|
||||||
|
freep(p);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p[i][0] ==_T('"'))
|
||||||
|
{
|
||||||
|
title = (p[i]+1);
|
||||||
|
*_tcschr(p[i]+1,_T('"'))=0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
title = p[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(title)
|
||||||
|
SetConsoleTitle(title);
|
||||||
|
|
||||||
|
hWnd=GetConsoleWindow();
|
||||||
|
|
||||||
|
wp.length=sizeof(WINDOWPLACEMENT);
|
||||||
|
GetWindowPlacement(hWnd,&wp);
|
||||||
|
|
||||||
|
if(iAction & A_POS)
|
||||||
|
{
|
||||||
|
wp.rcNormalPosition = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(iAction & A_MIN)
|
||||||
|
wp.showCmd=SW_MINIMIZE;
|
||||||
|
|
||||||
|
if(iAction & A_MAX)
|
||||||
|
wp.showCmd=SW_SHOWMAXIMIZED;
|
||||||
|
|
||||||
|
if(iAction & A_RESTORE)
|
||||||
|
wp.showCmd=SW_RESTORE;
|
||||||
|
|
||||||
|
wp.length=sizeof(WINDOWPLACEMENT);
|
||||||
|
SetWindowPlacement(hWnd,&wp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CMD_WINDOW */
|
Loading…
Add table
Add a link
Reference in a new issue