如何使嵌入两个不同的应用程序在一个窗口形式?
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?
不要只需要proccess.start()......
Don't need only proccess.start()....
我想你可能会寻找的的setparent的Windows API调用。
要做到这一点,你需要导入相关的API调用:
To do this, you'd need to import the relevant API call:
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
using指令添加到文件的顶部:
Add using directives at the top of the file:
using System.Diagnostics;
using System.Runtime.InteropServices;
启动外部和调用的setparent
就可以了(我们在这里使用记事本):
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.