C# Windows Forms and processes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I would like to know if it is possible to have a process (such as a command
prompt or notepad) running as a child of an MDI Windows Form, i.e. a process
that runs inside a window form and does not run separately.

Thanks,
Guillermo Lopez
 
Guillermo,

Maybe somebody else understands what you want, however at least I don not.

Cor
 
Maybe I didn't explain it detail, here is a better explanation:

Part of the code to display a windows form:

Application.Run(new Form1());

Then set property “IsMdiContainer = true†to determine that this window form
can itself contain more window forms.

Part of the code to display a windows form (a child) inside another (the
parent):

Child formChild = new Child();
formChild.MdiParent = this; // set parent
formChild.Show(); // display child


Part of the code to start a process:

Process p = new Process();
p.StartInfo.FileName="notepad.exe";
p.Start();

This process will start in a new window, independent of the parent window
form. My question is: how can I make this process to run as a child of the
parent window form (as a window inside the parent window form)?


Hope this is clearer,
Guillermo
 
Guillermo,

AFAIK can you not. The only thing that you can do it keep track on it. What
than fullfils probably your need by catching the output or by something as
beneath or the waitforexit in the process as bellow. (Pinging a http adres
using the proces). (There are things as the axwebbrowser what makes it
possible using interop).


http://msdn.microsoft.com/library/d...emdiagnosticsprocessclasswaitforexittopic.asp

\\\
Process p = new Process();
ProcessStartInfo pi = new ProcessStartInfo();
pi.UseShellExecute = false;
pi.RedirectStandardOutput = true;
pi.Arguments = "www.google.com";
pi.WorkingDirectory = "C:\\windows\\system32";
//this for nt* computers
pi.FileName = "ping";
p.StartInfo = pi;
p.Start();
System.IO.StreamReader sr = p.StandardOutput;
System.Text.StringBuilder sb = new System.Text.StringBuilder("");
int input = sr.Read();
while (input != -1)
{
sb.Append((char) input);
input = sr.Read();
}
MessageBox.Show(sb.ToString());
///

I hope this helps

Cor
 
Not sure if this will work, but worth a try. There is a windows API that you
can import called SetParent. Once you start Notepad you could find the
handle of the main window, call set parent passing the handle of your MDI
window.

http://msdn.microsoft.com/library/d...windowreference/windowfunctions/setparent.asp

--
Thanks
Wayne Sepega
Jacksonville, Fl


"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein
 
Back
Top