Embedding different applications in a Win Form in .NET

你。 提交于 2019-12-08 02:45:27

问题


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:


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.



来源:https://stackoverflow.com/questions/7083969/embedding-different-applications-in-a-win-form-in-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!