-1

What i'm trying to do is to take over another running application and attach it to a panel in my Form, somthing like this:

   private void button1_Click(object sender, EventArgs e)
    {
        Process p = Process.Start("notepad.exe");
        Thread.Sleep(500); // Allow the process to open it's window
        SetParent(p.MainWindowHandle, panel1.Handle);
    }

but in my case i won't Start the app, i will have to take over existing, running process.

Ideas?

Thanks in advance, Dan.

Dan Burdetsky
  • 101
  • 2
  • 8
  • Your code workks fine here. You will need to move the process to the origin of your panel.. See [here](http://stackoverflow.com/questions/5836176/docking-window-inside-another-window) – TaW Jun 28 '15 at 12:48

1 Answers1

0

Try this:

foreach (var process in Process.GetProcesses())
{
    if (process.ProcessName == "notepad")
    // or
    //if (process.MainWindowTitle == "Untitled - Notepad")
    {
        SetParent(process.MainWindowHandle, panel1.Handle);
    }
};
Alexander Petrov
  • 13,457
  • 2
  • 20
  • 49