views:

1470

answers:

1

I am writing an application and I would like to be able to display another application inside it. (Think like a windows form with a small box, or a tab that is displaying a totally seperate application.)

Is that something that can be done? If so, can anyone give some direction on how to go about doing it?

I am looking for something in the C# or VB.NET world.

THANKS!

+7  A: 

You need a hWnd (handle) of window from another application. Then you need a hWnd of container control in you application (System.Windows.Forms.Control.Handle property).

Then you need use a Win32API function SetParent, and that all you need. On the SetParent page is little sample, which should do what you need.

TcKs
Of course, this requires the window you want to embed already exists- otherwise you couldn't get it's handle. But it's still pretty slick: upvote.
Joel Coehoorn
You always need the window exist, if you want embed it into your container. Did you anytime add something "A" into something "B" when "A" did not exists :)?The question is "how can I find the window, which I want".You can use "Process.MainWindowHandle" property or "EnumWindows" Win32API function.
TcKs