简体   繁体   English

在WPF浮动撕下选项卡中托管Win32窗口

[英]Hosting a Win32 window in a WPF floating tear off tab

I am currently hosting a Win32 OSG (built on OpenGL) control in WPF. 我目前在WPF中托管Win32 OSG(基于OpenGL构建)控件。 I am using the telerik docking library. 我正在使用telerik扩展坞。 Everything works fine when a pane is docked with the MainWindow. 当窗格与MainWindow停靠在一起时,一切正常。 However, when I tear off the tab, the OSG graphics are not recreated in the tear off tab . 但是,当我撕下标签时, 不会在撕下标签中重新创建OSG图形

I am subclassing HwndHost which uses CreateWindowEx to create a native Win32 host and returns the native handle (see code below). 我将HwndHost子类HwndHost ,后者使用CreateWindowEx创建本机Win32主机并返回本机句柄(请参见下面的代码)。 I then pass that handle to the native OSG code which is being hosted by a user control. 然后,我将该句柄传递给由用户控件托管的本机OSG代码。

    // inside my ControlHost class which derives from HwndHost
    protected override HandleRef BuildWindowCore(HandleRef hwndParent)
    {
        hwndControl = IntPtr.Zero;
        hwndHost = IntPtr.Zero;

        hwndHost = CreateWindowEx(0, "MDIClient", "",
                                  WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
                                  0, 0,
                                  hostHeight, hostWidth,
                                  hwndParent.Handle,
                                  (IntPtr)HOST_ID,
                                  IntPtr.Zero,
                                  0);
        return new HandleRef(this, hwndHost);
    }

When debugging into the above method, as expected, the hwndParent.handle parameter is the handle of the WPF MainWindow when the tab is docked in the Main window. 调试到上述方法时,按预期方式,当选项卡停靠在主窗口中时, hwndParent.handle参数是WPF MainWindow的句柄。 However, when I pull the tab out and it becomes a floating tab, the hwndParent.handle attribute is a value that I cannot find with Spy++. 但是,当我拉出选项卡并将其变成浮动选项卡时, hwndParent.handle属性是我无法在Spy ++中找到的值。 The floating tab 'hwnd` value according to Spy++ is the same as that produced by the above method. Spy ++的浮动标签“ hwnd”值与上述方法产生的值相同。 I suspect this may be the reason why the OSG graphics are not displaying. 我怀疑这可能是OSG图形未显示的原因。

My questions are: 我的问题是:

  1. I know natively with WPF there is only a HWND associated with each Window object, however how does this work with floating panels in docking libraries? 我本来就知道使用WPF,每个Window对象都只有一个HWND,但是这如何与停靠库中的浮动面板一起使用? Are the floating panels actually a window as the underlying object or a usercontrol? 浮动面板实际上是作为基础对象还是用户控件的窗口?

  2. Any ideas why my native OSG graphics are not being displayed on the floating tear off tab? 有什么想法为什么我的本机OSG图形未显示在浮动撕下选项卡上? Is it related to the parent handle that is being passed in? 它与传入的父句柄有关吗?

The RadDocking control uses transparent WPF windows to display its ToolWindows by default and as a platform limitation of WPF, you cannot display any non-WPF content in such transparent windows. RadDocking控件默认使用透明的WPF窗口显示其ToolWindows,并且作为WPF的平台限制,您不能在此类透明窗口中显示任何非WPF内容。 What you could do is to make the windows non-transparent by setting the RadWindowInteropHelper.AllowTransparency attached property of ToolWindow to False. 您可以通过将ToolWindow的RadWindowInteropHelper.AllowTransparency附加属性设置为False来使窗口不透明。 This could be achieved using a custom GeneratedItemsFactory. 这可以通过使用自定义的GeneratedItemsFactory来实现。 Please refer to this forum thread for as sample project. 请参考此论坛主题作为示例项目。

Regards, Miroslav Nedyalkov, Telerik team. 此致,特里里克(Telerik)队的米罗斯拉夫·涅迪亚科夫(Miroslav Nedyalkov)。

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

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