Embedding different applications in a Win Form in

2019-05-28 13:53发布

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()....

1条回答
仙女界的扛把子
2楼-- · 2019-05-28 14:29

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.

查看更多
登录 后发表回答