[英]How to embed a native window handler (HWND) into a C# WPF app
I'm working on an application for making video calls using pjsip.我正在开发一个使用 pjsip 进行视频通话的应用程序。
I have:我有:
The WPF app can open the capture device. WPF 应用程序可以打开捕获设备。 Pjsip creates a sdl window for the video preview, and returns its HWND as a void* in the C++ side. Pjsip 为视频预览创建了一个 sdl 窗口,并在 C++ 端将其 HWND 作为 void* 返回。
I am "casting" it into a std::string -- using std::stringstream stream operators -- and marshalling it to the WPF side.我将它“投射”到 std::string 中——使用 std::stringstream 流运算符——并将其编组到 WPF 端。
I'd like to embed that window into my WPF main window.我想将该窗口嵌入到我的 WPF 主窗口中。 Is that possible?那可能吗?
You can use HwndHost
class and host native windows in WPF.您可以在 WPF 中使用HwndHost
类并托管本机窗口。
HwndHost
is part of System.Windows.Interop
WPF namespace. HwndHost
是System.Windows.Interop
WPF 命名空间的一部分。
Here is Microsoft example, but it is little tedious.这是微软的例子,但它有点乏味。
https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-win32-control-in-wpf https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-win32-control-in-wpf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.