高分求解,winform&WPF

cppfaq 2010-04-23 06:48:52
请问各位大侠,能否将一个win32的top level window嵌入到wpf中去? 注意,不是嵌一个win32的控件(如listbox)。
...全文
153 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
足球中国 2010-04-24
  • 打赏
  • 举报
回复
纯观望 都没弄清楼主要弄的啥东西??
悔说话的哑巴 2010-04-24
  • 打赏
  • 举报
回复
这个只有友情UP了
ws_hgo 2010-04-24
  • 打赏
  • 举报
回复
........
K9998 2010-04-24
  • 打赏
  • 举报
回复
按说拿到句柄就可以嵌套了.
mars199 2010-04-23
  • 打赏
  • 举报
回复
不懂帮顶
li45214521 2010-04-23
  • 打赏
  • 举报
回复
win32的top level window 是什么?
可以告诉你的是,只要是window窗口东西基本上都可以嵌入的,
不过需要知道 这个是什么东西 才能知道具体方法
wjz748305545 2010-04-23
  • 打赏
  • 举报
回复
学习,顶个
xfate 2010-04-23
  • 打赏
  • 举报
回复
等待高手解决!
皇城龙三 2010-04-23
  • 打赏
  • 举报
回复
这个文章未必能解决问题,但是算是提供一种思路

使用VS2008创建WPF应用程序,需使用webbrowser。从工具箱中添加WPF组件中的webbrowser发现其中有很多属性事件不能使用。决定还是使用WinForm中的webbrowser。要想在WPF中使用WinForm控件,查看MSDN,需经过以下步骤。

创建名为 HostingWfInWpf 的 WPF 应用程序项目。

在解决方案资源管理器中,添加一个对名为 WindowsFormsIntegration.dll 的 WindowsFormsIntegration 程序集的引用。

在解决方案资源管理器中,添加一个对名为 System.Windows.Forms.dll 的 Windows 窗体程序集的引用。

在 WPF 设计器中打开 Window1.xaml。

用以下 XAML 替换 Window1.xaml 中自动生成的 XAML。

<Window x:Class="HostingWfInWpf.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="HostingWfInWpf"
Loaded="WindowLoaded"
>
<Grid Name="grid1">

</Grid>
</Window>
6.在代码编辑器中打开 Window1.xaml.cs。
7.将 Window1.xaml.cs 中的代码替换为以下代码。



using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;

using System.Windows.Forms;

namespace HostingWfInWpf
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void WindowLoaded(object sender, RoutedEventArgs e)
{
// Create the interop host control.
System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();

// Create the MaskedTextBox control.
MaskedTextBox mtbDate = new MaskedTextBox("00/00/0000");

// Assign the MaskedTextBox control as the host control's child.
host.Child = mtbDate;

// Add the interop host control to the Grid
// control's collection of child controls.
this.grid1.Children.Add(host);
}
}
}


此处,将MaskedTextBox换成System.Windows.Forms.WebBrowser即可。
ChrisAK 2010-04-23
  • 打赏
  • 举报
回复
没嵌入过...
试试用API吧.
SetParent.
另外要让那个窗体成为子控件的话必须让它有WS_CHILD样式
  • 打赏
  • 举报
回复
没用过 ,UP!~

110,548

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧