Click here to Skip to main content
15,914,162 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
See more:
Hello,

I would like to know how I can create a form using a button I call an application (. Exe) outside the project and is contained within the form.

I have seen many examples but I can not do it yet.

I am currently using Visual Studio 2010

Thanks in advance,

regards
Posted

1 solution

C#
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class Form1 : Form
{
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
public Form1()
{
Process proc = Process.Start("notepad.exe");
proc.WaitForInputIdle();
Form1.SetParent(proc.MainWindowHandle, this.Handle);
}
}
 
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