给定一个WPF Image控件,是否有可能确定其HWND? [英] Given a WPF Image control, is it possible to determine its HWND?

查看:212
本文介绍了给定一个WPF Image控件,是否有可能确定其HWND?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF应用程序集成网络摄像头。我可以看到在主窗口的摄像头的饲料,因为我传递给DirectShow的功能,它的句柄。但是,这不是我想要的。

I am integrating a webcam in a WPF application. I can see the camera feed in the main window, as I pass its HANDLE on to the DirectShow functions. But this is not what I want.

主要形式有一个Image控件,我想在这里看到的输出。然而,为了做到这一点,我需要控件的句柄。

The main form has a Image control, where I'd like to see the output. However, in order to do this, I need the control's Handle.

这是如何做到这一点的任何暗示?

Any hint on how to do this?

在此先感谢,
赞布罗塔。

Thanks in advance, Gianluca.

推荐答案

在WPF的图像控制,不像Windows窗体,实际上并不。有一个HWND

An Image Control in WPF, unlike Windows Forms, doesn't actually have an HWND.

WPF工作方式与Windows窗体 - 每个控制不在身边土生土长的窗口,带手柄的包装,但在运行时使用的Direct3D而组合在一起通过布局系统

WPF works differently than Windows Forms - each control is not a wrapper around a native "window" with a handle, but rather composed together using Direct3D at runtime by the layout system.

如果你需要真正从一个WPF窗口内的摄像头主机输出,你应该看看使用的HwndHost (或子类)。最简单的方法往往是刚刚举办的Windows窗体里面 WindowsFormsHost控件,虽然通过 HwndHost 管理​​一个HWND自己更有效率。

If you need to actually host output from a Webcam inside of a WPF window, you should look at using HwndHost (or a subclass). The simplest way is often to just host a Windows Forms control inside of a WindowsFormsHost, though managing an HWND yourself via HwndHost is more efficient.

这篇关于给定一个WPF Image控件,是否有可能确定其HWND?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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