From ee3dc0f0c1b88e841823d1857bb1d2ce0abd6566 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 24 Sep 1999 22:03:11 +0000 Subject: [PATCH] Added window command. svn path=/trunk/; revision=669 --- rosapps/cmd/cmd.h | 6 +- rosapps/cmd/cmdtable.c | 4 + rosapps/cmd/config.h | 3 + rosapps/cmd/makefile | 4 +- rosapps/cmd/misc.c | 29 +++++++ rosapps/cmd/msgbox.c | 27 +----- rosapps/cmd/window.c | 181 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 226 insertions(+), 28 deletions(-) create mode 100644 rosapps/cmd/window.c diff --git a/rosapps/cmd/cmd.h b/rosapps/cmd/cmd.h index 24276f3ad14..28e25b7652e 100644 --- a/rosapps/cmd/cmd.h +++ b/rosapps/cmd/cmd.h @@ -287,6 +287,9 @@ BOOL IsValidPathName (LPCTSTR); BOOL IsValidFileName (LPCTSTR); BOOL IsValidDirectory (LPCTSTR); BOOL FileGetString (HANDLE, LPTSTR, INT); +#ifndef __REACTOS__ +HWND GetConsoleWindow(VOID); +#endif /* Prototypes for MOVE.C */ @@ -363,7 +366,8 @@ INT cmd_vol (LPTSTR, LPTSTR); /* Prototypes for WHERE.C */ 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] */ diff --git a/rosapps/cmd/cmdtable.c b/rosapps/cmd/cmdtable.c index 352118e14d4..fc8a48366cb 100644 --- a/rosapps/cmd/cmdtable.c +++ b/rosapps/cmd/cmdtable.c @@ -217,6 +217,10 @@ COMMAND cmds[] = {_T("vol"), 0, cmd_vol}, #endif +#ifdef INCLUDE_CMD_WINDOW + {_T("window"), 0, CommandWindow}, +#endif + {NULL, 0, NULL} }; diff --git a/rosapps/cmd/config.h b/rosapps/cmd/config.h index 591d3727b4a..2a931032656 100644 --- a/rosapps/cmd/config.h +++ b/rosapps/cmd/config.h @@ -95,6 +95,9 @@ #define INCLUDE_CMD_BEEP #define INCLUDE_CMD_VERIFY #define INCLUDE_CMD_VOL +#ifndef __REACTOS__ +#define INCLUDE_CMD_WINDOW +#endif /* commands that do not have a define: diff --git a/rosapps/cmd/makefile b/rosapps/cmd/makefile index 61a37821d10..9a906c3b164 100644 --- a/rosapps/cmd/makefile +++ b/rosapps/cmd/makefile @@ -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 \ 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 \ - 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 @@ -46,7 +46,7 @@ $(TARGET:%=../$(DIST_DIR)/apps/%): ../$(DIST_DIR)/apps/%: % ifeq ($(DOSCLI),yes) $(CP) $* ..\$(DIST_DIR)\apps\$* else - $(CP) $* ../$(DIST_DIR)/apps/$* + $(CP) $* ../$(DIST_DIR)/apps\$* endif include ../rules.mak diff --git a/rosapps/cmd/misc.c b/rosapps/cmd/misc.c index 26c6b14b45b..65231823c97 100644 --- a/rosapps/cmd/misc.c +++ b/rosapps/cmd/misc.c @@ -295,3 +295,32 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength) 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 */ \ No newline at end of file diff --git a/rosapps/cmd/msgbox.c b/rosapps/cmd/msgbox.c index f6d3354694c..c04e2bba29e 100644 --- a/rosapps/cmd/msgbox.c +++ b/rosapps/cmd/msgbox.c @@ -27,30 +27,6 @@ #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) { //used to parse command line @@ -171,7 +147,8 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param) prompt = param; hWnd=GetConsoleWindow (); - //DebugPrintf("FindWindow hWnd = %d\n",hWnd); +// DebugPrintf("FindWindow hWnd = %d\n",hWnd); + ConErrPrintf("FindWindow hWnd = %d\n",hWnd); switch ( MessageBox(hWnd,prompt,title,uType) diff --git a/rosapps/cmd/window.c b/rosapps/cmd/window.c new file mode 100644 index 00000000000..4e207b58ae8 --- /dev/null +++ b/rosapps/cmd/window.c @@ -0,0 +1,181 @@ +/* + * WINDOW.C - internal command. + * + * clone from 4nt window command + * + * 10 Sep 1999 + * started - Dr.F + * + * + */ + +#include "config.h" + +#ifdef INCLUDE_CMD_WINDOW + +#include "cmd.h" +#include +#include +#include +#include + + +#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