471,344 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 software developers and data experts.

C# Windows Forms and processes

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
Jul 21 '05 #1
5 4699
Guillermo,

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

Cor
Jul 21 '05 #2
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
Jul 21 '05 #3
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/de...rexittopic.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
Jul 21 '05 #4
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/de.../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

"Guillermo Lopez" <Gu************@discussions.microsoft.com> wrote in
message news:ED**********************************@microsof t.com...
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

Jul 21 '05 #5
Thanks Wayne,

That's what I was looking for.
I also found this website with an example of what I need to do:
http://codeproject.com/useritems/ByPassAutomation.asp

Regards,
Guillermo Lopez

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Ayende Rahien | last post: by
14 posts views Thread by Brian Keating EI9FXB | last post: by
reply views Thread by gxl034000 | last post: by
21 posts views Thread by Dan Tallent | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.