Hosting a Win32 window in a WPF floating tear off tab

I am currently hosting a Win32 OSG (built on OpenGL) control in WPF. I am using the telerik docking library. Everything works fine when a pane is docked with the MainWindow. However, when I tear off the tab, the OSG graphics are not recreated in the tear off tab .

I am subclassing HwndHost which uses CreateWindowEx to create a native Win32 host and returns the native handle (see code below). I then pass that handle to the native OSG code which is being hosted by a user control.

    // 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. 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++. The floating tab 'hwnd` value according to Spy++ is the same as that produced by the above method. I suspect this may be the reason why the OSG graphics are not displaying.

My questions are:

  • 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? Are the floating panels actually a window as the underlying object or a usercontrol?

  • Any ideas why my native OSG graphics are not being displayed on the floating tear off tab? 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. What you could do is to make the windows non-transparent by setting the RadWindowInteropHelper.AllowTransparency attached property of ToolWindow to False. This could be achieved using a custom GeneratedItemsFactory. Please refer to this forum thread for as sample project.

    Regards, Miroslav Nedyalkov, Telerik team.

    链接地址: http://www.djcxy.com/p/41198.html

    上一篇: 在选项卡c ++中创建窗口

    下一篇: 在WPF浮动分离选项卡中托管Win32窗口