Click here to Skip to main content
15,898,978 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please, I want to know how can I shell an exe from my application but in the same time how can I make the caller form to be the owner of the shelled process window, like that code:
this.AddOwnedForm([the shelled process window]);

Thank you.
Posted
Updated 17-Nov-10 18:31pm
v2

1 solution

You need to get the handle of the main window of the Process you launched. Look into the Process class and you'll find it. You will probably have to wait for the Process to completely start before you can get the main window handle. There is a property for that also in the Process class.

When you have that, you cal call the Win32 API function SetParent to put the window of the launched process inside the window of whatever container control you want, like a Panel. All you need is your Panel control's window handle, see its Handle property.

The app you launch will show its window outside of your app for a briefe moment before it ends up inside your application window. There is no way to avoid this.
 
Share this answer
 

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