WPF控件中的Native Win32窗口 [英] Native Win32 window in WPF Control

查看:566
本文介绍了WPF控件中的Native Win32窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要主机本地Win32窗口的应用程序,我不知道如何做。

I am developing an application that needs to a host native Win32 window and somehow i have no clues how to do that.

我需要创建一个WPF对话窗口它可以显示本机Win32控件上。这个对话框窗口也将有WPF控件,所以我正在寻找一些网格,我可以采取HWND和发送到非托管C ++控件,所以它可以画它。
这是可能吗?

I need to create a WPF dialog window that could display native Win32 control on it. This dialog window will have WPF controls on it as well, so i am looking for some sort of Grid that i could take HWND of and send it to the unmanaged C++ control, so it could draw on it. Is that possible ?

我不需要知道在那个表面内发生了什么,只需要让C ++ dll来绘制它,要做的是传递具有适当大小的HWND(我知道)。

I don't need to know what happens within that surface, just need to let C++ dll to draw on it and all i need to do is to pass HWND that has proper size (which i know).

我有点新WPF(用于做win32编程)现在如何将它连接到C#.NET等)

I am kinda new to WPF (used to do win32 programming) and quite lost (but i now how to interface it to C# .NET etc)

如果你可以给我任何提示:)

Would be great if you could send me any hints :)

推荐答案

您可以先按照以下说明/步骤操作:在WPF中托管Win32内容

you can start by following the instructions/steps here: Hosting Win32 Content in WPF

在WPF中托管Win32内容

from the article introduction:

Win32内部Windows表示框架(HwndHost)

A Walkthrough of Win32 Inside Windows Presentation Framework (HwndHost)


要在WPF应用程序中重用Win32内容,使用HwndHost,
a控制使HWNDs看起来像WPF内容。像HwndSource,
HwndHost可以直接使用:从HwndHost派生并实现
BuildWindowCore和DestroyWindowCore方法,然后实例化你的
HwndHost派生类,并将它放在你的WPF应用程序中。

To reuse Win32 content inside WPF applications, use HwndHost, which is a control that makes HWNDs look like WPF content. Like HwndSource, HwndHost is straightforward to use: derive from HwndHost and implement BuildWindowCore and DestroyWindowCore methods, then instantiate your HwndHost derived class and place it inside your WPF application.

如果你的Win32逻辑已经打包成一个控件,那么你的
BuildWindowCore实现只是调用
CreateWindow。

If your Win32 logic is already packaged as a control, then your BuildWindowCore implementation is little more than a call to CreateWindow.

那么如果你有一个特定的问题在这里请问SO,人们会帮助你在具体的点。

then if you have a specific issue ask here in SO and people will help you on specific points.

这篇关于WPF控件中的Native Win32窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆