Winform嵌入其它应用程序
2017-10-23 12:09
357 查看
Options:
View Code
private void ShowBrowser(string url) { if (dkPnl.Children.Count > 0) { WindowsFormsHost whst = dkPnl.Children[0] as WindowsFormsHost; whst.Dispose(); foreach (Process p in Process.GetProcessesByName("MyBrowser")) { p.Kill(); } } var host = new ApplicationHost() { File = @"MyBrowser.exe", Arguments = string.Empty, HideApplicationTitleBar = true, Dock = System.Windows.Forms.DockStyle.Fill, BorderStyle = System.Windows.Forms.BorderStyle.None }; host.ProcessLoaded += host_ProcessLoaded; host.ProcessUnLoaded += host_ProcessUnLoaded; WindowsFormsHost windowsFormsHost = new WindowsFormsHost(); windowsFormsHost.Child = host; dkPnl.Children.Add(windowsFormsHost); } private Dictionary<IntPtr, ApplicationHost> _hostPool; private Dictionary<IntPtr, ApplicationHost> m_HostPool { get { return _hostPool ?? (_hostPool = new Dictionary<IntPtr, ApplicationHost>()); } } void host_ProcessLoaded(object sender, EventArgs e) { var host = sender as ApplicationHost; m_HostPool.Add(host.MainWindowHandle, host); } void host_ProcessUnLoaded(object sender, EventArgs e) { var host = sender as ApplicationHost; var parent = host.Parent; if (parent != null && !parent.IsDisposed) { parent.Dispose(); } }
View Code
相关文章推荐
- WinForm将其它应用程序窗体嵌入自己内部
- C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- 【转】C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- 【转】C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部【转载】
- winform窗体中嵌入网页(DHTML代码和winfrom应用程序交互)
- 在WinForm应用程序中嵌入WPF控件
- winform窗体中嵌入网页(DHTML代码和winfrom应用程序交互)
- 在WinForm应用程序中嵌入WPF控件
- 在WinForm应用程序中嵌入WPF控件
- 在WinForm应用程序中嵌入WPF控件
- 将外部应用程序嵌入WinForm中
- 在winform嵌入外部应用程序
- 将外部应用程序嵌入WinForm中
- 在WinForm应用程序中嵌入WPF控件(转)