summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-08-05 19:10:33 (GMT)
committerBrad King <brad.king@kitware.com>2003-08-05 19:10:33 (GMT)
commit59d886d0f4822aecd7744ce06a47438dc9a09046 (patch)
tree553153d05d8995e7fe64511e1756d55099b7d12f
parent27289e32678663b8d71b842b9e8e5b1b5909d30f (diff)
downloadCMake-59d886d0f4822aecd7744ce06a47438dc9a09046.zip
CMake-59d886d0f4822aecd7744ce06a47438dc9a09046.tar.gz
CMake-59d886d0f4822aecd7744ce06a47438dc9a09046.tar.bz2
ENH: Added show/hide window support.
-rw-r--r--Source/kwsys/ProcessFwd9x.c10
-rw-r--r--Source/kwsys/ProcessWin32.c44
2 files changed, 31 insertions, 23 deletions
diff --git a/Source/kwsys/ProcessFwd9x.c b/Source/kwsys/ProcessFwd9x.c
index b837bf5..7c03a68 100644
--- a/Source/kwsys/ProcessFwd9x.c
+++ b/Source/kwsys/ProcessFwd9x.c
@@ -54,6 +54,9 @@ int main()
This is parsed off the command line. */
HANDLE killEvent = 0;
+ /* Flag for whether to hide window of child process. */
+ int hideWindow = 0;
+
/* An array of the handles on which we wait when the child is
running. */
HANDLE waitHandles[2] = {0, 0};
@@ -79,6 +82,11 @@ int main()
while(*cmdLine && *cmdLine == ' ') { ++cmdLine; }
sscanf(cmdLine, "%p", &killEvent);
+ /* Parse the hide window flag. */
+ while(*cmdLine && *cmdLine != ' ') { ++cmdLine; }
+ while(*cmdLine && *cmdLine == ' ') { ++cmdLine; }
+ sscanf(cmdLine, "%d", &hideWindow);
+
/* Skip to the beginning of the command line of the real child. */
while(*cmdLine && *cmdLine != ' ') { ++cmdLine; }
while(*cmdLine && *cmdLine == ' ') { ++cmdLine; }
@@ -88,7 +96,7 @@ int main()
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
- si.wShowWindow = SW_SHOWDEFAULT;
+ si.wShowWindow = hideWindow?SW_HIDE:SW_SHOWDEFAULT;
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index 1735782..84c1bdd 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -140,6 +140,9 @@ struct kwsysProcess_s
/* The working directory for the child process. */
char* WorkingDirectory;
+ /* Whether to hide the child process's window. */
+ int HideWindow;
+
/* On Win9x platforms, the path to the forwarding executable. */
char* Win9x;
@@ -638,17 +641,21 @@ void kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
/*--------------------------------------------------------------------------*/
int kwsysProcess_GetOption(kwsysProcess* cp, int optionId)
{
- (void)cp;
- (void)optionId;
- return 0;
+ switch(optionId)
+ {
+ case kwsysProcess_Option_HideWindow: return cp->HideWindow;
+ default: return 0;
+ }
}
/*--------------------------------------------------------------------------*/
void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value)
{
- (void)cp;
- (void)optionId;
- (void)value;
+ switch(optionId)
+ {
+ case kwsysProcess_Option_HideWindow: cp->HideWindow = value; break;
+ default: break;
+ }
}
/*--------------------------------------------------------------------------*/
@@ -692,6 +699,7 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* Windows child startup control data. */
STARTUPINFO si;
+ DWORD dwCreationFlags=0;
/* Do not execute a second time. */
if(cp->State == kwsysProcess_State_Executing)
@@ -761,39 +769,31 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* The forwarding executable is given a handle to the error pipe
and a handle to the kill event. */
cp->RealCommand = malloc(strlen(cp->Win9x)+strlen(cp->Command)+100);
- sprintf(cp->RealCommand, "%s %p %p %s", cp->Win9x,
- cp->Pipe[CMPE_PIPE_ERROR].Write,
- cp->Win9xKillEvent, cp->Command);
+ sprintf(cp->RealCommand, "%s %p %p %d %s", cp->Win9x,
+ cp->Pipe[CMPE_PIPE_ERROR].Write, cp->Win9xKillEvent,
+ cp->HideWindow, cp->Command);
}
else
{
/* Not Windows 9x */
cp->RealCommand = strdup(cp->Command);
}
-
+
/* Connect the child's output pipes to the threads. */
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdOutput = cp->Pipe[CMPE_PIPE_STDOUT].Write;
si.hStdError = cp->Pipe[CMPE_PIPE_STDERR].Write;
- /* Hide the forwarding executable console on Windows 9x. */
- si.dwFlags |= STARTF_USESHOWWINDOW;
- if(cp->Win9x)
- {
- si.wShowWindow = SW_HIDE;
- }
- else
- {
- si.wShowWindow = SW_SHOWDEFAULT;
- }
+ /* Decide whether a child window should be shown. */
+ si.dwFlags |= STARTF_USESHOWWINDOW;
+ si.wShowWindow = cp->HideWindow?SW_HIDE:SW_SHOWDEFAULT;
/* The timeout period starts now. */
cp->StartTime = kwsysProcessTimeGetCurrent();
cp->TimeoutTime = kwsysProcessTimeFromDouble(-1);
/* CREATE THE CHILD PROCESS */
- if(!CreateProcess(0, cp->RealCommand, 0, 0, TRUE,
- cp->Win9x? CREATE_NEW_CONSOLE:DETACHED_PROCESS, 0,
+ if(!CreateProcess(0, cp->RealCommand, 0, 0, TRUE, dwCreationFlags, 0,
cp->WorkingDirectory, &si, &cp->ProcessInformation))
{
kwsysProcessCleanup(cp, 1);