简体   繁体   English

WPF控件中的本机Win32窗口

[英]Native Win32 window in WPF Control

I am developing an application that needs to a host native Win32 window and somehow i have no clues how to do that. 我正在开发一个需要主机本机Win32窗口的应用程序,不知怎的,我没有线索如何做到这一点。

I need to create a WPF dialog window that could display native Win32 control on it. 我需要创建一个WPF对话框窗口,可以在其上显示本机Win32控件。 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. 这个对话框窗口上也会有WPF控件,所以我正在寻找某种Grid,我可以把它带到HWND并将它发送到非托管C ++控件,所以它可以在它上面绘制。 Is that possible ? 那可能吗 ?

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). 我不需要知道该表面内发生了什么,只需要让C ++ dll绘制它,我需要做的就是传递具有适当大小的HWND(我知道)。

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) 我是WPF的新手(用于做win32编程)并且很丢失(但我现在如何将它与C#.NET等接口)

Would be great if you could send me any hints :) 如果你能给我任何提示,那会很棒:)

you can start by following the instructions/steps here: Hosting Win32 Content in WPF 您可以按照此处的说明/步骤开始: 在WPF中托管Win32内容

from the article introduction: 从文章介绍:

A Walkthrough of Win32 Inside Windows Presentation Framework (HwndHost) Windows演示框架内的Win32演练(HwndHost)

To reuse Win32 content inside WPF applications, use HwndHost, which is a control that makes HWNDs look like WPF content. 要在WPF应用程序中重用Win32内容,请使用HwndHost,它是使HWND看起来像WPF内容的控件。 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. 与HwndSource一样,HwndHost很容易使用:派生自HwndHost并实现BuildWindowCore和DestroyWindowCore方法,然后实例化你的HwndHost派生类并将其放在WPF应用程序中。

If your Win32 logic is already packaged as a control, then your BuildWindowCore implementation is little more than a call to CreateWindow. 如果你的Win32逻辑已经打包为控件,那么你的BuildWindowCore实现只不过是对CreateWindow的调用。

then if you have a specific issue ask here in SO and people will help you on specific points. 那么,如果您有特定问题,请在此处询问,人们会在特定点上帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM