日期:2014-05-19  浏览次数:20884 次

如何将外部应用程序(例如计算器)作为当前程序的子窗体
让计算器和自己制作的子窗体一样只能在主窗体的内部移动.如何实现,谢谢.

------解决方案--------------------
参考如下:

[DllImport( "user32.dll ", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);

Process p = Process.Start(@ "C:\Windows\system32\calc.exe ");
while (p.WaitForInputIdle())
{
if (p.MainWindowHandle != IntPtr.Zero)
{
SetParent(p.MainWindowHandle, this.Handle);
break;
}
}