[英]Moving panel with directshow video renderer in it
我有一些綁定了不同DirectShow IVideoWindow手柄的面板,以便使視頻顯示在面板內部(WindowStyle屬性是:Child,ClipSiblings,ClipChildren,Caption)現在我想移動這些面板,但是我只能當視頻內容未填滿整個面板時,請在空白面板空間上單擊並按住鼠標按鈕。 我可以在面板中四處移動視頻窗口,但是當然它們只能在各自的面板空間內移動。
有沒有一種方法可以將視頻窗口內容直接綁定到面板上,例如,當我單擊並按住視頻窗口菜單欄時,帶有內容的整個面板可以自由移動?
提前致謝。
忘記了,這是在C#中。
我使用了Video Mixing Renderer 9,並將其綁定到用戶控件上。 我已將VMR9設置為“無窗口”模式,然后將IVMRWindowlessControl9界面上的視頻剪輯窗口設置為用戶控件的句柄。 每當面板調整大小時,我還使用IVMRWindowlessControl9.GetNativeVideoSize,IVMRWindowlessControl9.SetAspectRatioMode和IVMRWindowlessControl9.SetVideoPosition設置視頻完全填充面板。 當包含我的用戶控件的表單到處移動時,視頻也會隨之而來。 這一切都是通過C#和DirectShow.NET完成的。
編輯后添加示例代碼:
public partial class VideoPanel : UserControl
{
private VideoMixingRenderer9 _renderer;
private IVMRWindowlessControl9 _windowlessControl;
public VideoMixingRenderer9 Renderer
{
get
{
return _renderer;
}
set
{
_renderer = value;
if (_renderer != null)
{
var filterConfig = _renderer as IVMRFilterConfig9;
if (filterConfig != null)
{
filterConfig.SetRenderingMode(VMR9Mode.Windowless);
_windowlessControl = _renderer as IVMRWindowlessControl9;
if (_windowlessControl != null)
{
_windowlessControl.SetVideoClippingWindow(Handle);
SetSize();
}
}
}
}
}
private void SetSize()
{
var srcRect = new DsRect();
var dstRect = new DsRect(ClientRectangle);
int arWidth, arHeight;
_windowlessControl.GetNativeVideoSize(out srcRect.right, out srcRect.bottom, out arWidth, out arHeight);
_windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox);
_windowlessControl.SetVideoPosition(srcRect, dstRect);
}
}
我終於解決了,我簡直不敢相信自己有多傻。 我省了
hr = videoWindow.put_MessageDrain(hWin.Handle);
line,當然,視頻窗口不會“監聽”面板。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.