Click here to Skip to main content
15,991,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Windows form program that spawns a child process(.exe). Upon execution the child becomes the active window. How can I return control to the parent so that it is the active window programatically.
Posted

1 solution

Me.Activate()


Of course, you can only execute that line of code after the child .EXE launches as shows its main window. Look at the documentation on the Process class and you'll see a method called "WaitForInputIdle".
 
Share this answer
 
Comments
[no name] 19-Jan-12 15:36pm    
//tried - to no avail
//RMshow is a simple little picture display:

string prog = Application.StartupPath + "\\RMshow.exe";
System.Diagnostics.Process.Start(prog, "\x22" + picname + "\x22");
this.Activate();
[no name] 19-Jan-12 16:01pm    
It would seem to me there should be some way to Activate the parent or Deactivate the child. I would be happy to alter either piece of code. There is a Deactivate command but it only reports if the client has been deactivated. I can find no way to force deactivation of the child or activate the parent.
[no name] 19-Jan-12 17:53pm    
Thanks for your comment Dave it led me to investigate timing issues. Putting this.Activate() on a three second timer solved the problem.
Dave Kreskowiak 19-Jan-12 20:10pm    
Yeah, but what if, for some reason, it takes longer than 3 seconds to start?? It's possible...
[no name] 20-Jan-12 5:56am    
I tried to use the method you suggested but could not write anything that would compile. Could you give me a piece of sample code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900