首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >插件环境下的CEFGlue不呈现

插件环境下的CEFGlue不呈现
EN

Stack Overflow用户
提问于 2016-08-17 08:37:47
回答 1查看 123关注 0票数 0

我一直在引用CEFGlue示例中的“https://bitbucket.org/xilium/xilium.cefglue/downloads”,并试图将其集成到插件程序集中。无论我做什么,当作为插件运行时,浏览器控件都不会在视图中得到呈现。但是,当在独立模式下运行时,这是很好的。有人能告诉我怎么走吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-19 09:09:34

所以我找到了控件没有出现的根本原因。在CEFGlue代码库中的某个地方是下面的一行,这使得它一直遍历可视树,查找类型“window”,从而获得它的父窗口句柄并呈现CEFBrowser控件的UI。

代码语言:javascript
复制
Window parentWnd = FindParentOfType<Window>(this);

private static T FindParentOfType<T>(DependencyObject obj) where T : DependencyObject
        {
            DependencyObject parentObj = VisualTreeHelper.GetParent(obj);
            if (parentObj == null)
                return null;

            // Try to type cast the parent to the desired type.
            // If the cast succeeds, we've found the desired parent.
            T parent = parentObj as T;
            if (parent != null)
                return parent;

            // If we get here, the current parent wasn't of the right type, so keep looking recursively
            return FindParentOfType<T>(parentObj);
        }

可能是因为我的插件环境,这个可视树没有那种父窗口,导致一个空句柄。因此,在我的例子中,解决方案是找到父进程的主窗口句柄,并将其交给CEF。希望它能帮助一些有类似情况的人。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38991823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档