我一直在引用CEFGlue示例中的“https://bitbucket.org/xilium/xilium.cefglue/downloads”,并试图将其集成到插件程序集中。无论我做什么,当作为插件运行时,浏览器控件都不会在视图中得到呈现。但是,当在独立模式下运行时,这是很好的。有人能告诉我怎么走吗?
发布于 2016-08-19 09:09:34
所以我找到了控件没有出现的根本原因。在CEFGlue代码库中的某个地方是下面的一行,这使得它一直遍历可视树,查找类型“window”,从而获得它的父窗口句柄并呈现CEFBrowser控件的UI。
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。希望它能帮助一些有类似情况的人。
https://stackoverflow.com/questions/38991823
复制相似问题