2

How to embedd two different applications in a single windows form?

Suppose I have an application abour calculations and about web cam and I want them to show in a form?

Don't need only proccess.start()....

levi
  • 3,451
  • 6
  • 50
  • 86

1 Answers1

3

I think you may be looking for the SetParent Windows API call.

To do this, you'd need to import the relevant API call:

[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

Add using directives at the top of the file:

using System.Diagnostics;
using System.Runtime.InteropServices;

Start the external and call SetParent on it (we are using notepad here):

Process notepad = new Process();
ProcessStartInfo psi = new ProcessStartInfo("notepad.exe");
psi.WindowStyle = ProcessWindowStyle.Normal;
notepad.StartInfo = psi;

notepad.Start();
notepad.WaitForInputIdle(3000);            

SetParent(notepad.MainWindowHandle, this.Handle);

This should work, but I've experienced some strange behaviour with it, in general, I would avoid it if possible.

Daniel B
  • 2,877
  • 18
  • 18