提交当前本机整理版本
This commit is contained in:
@@ -188,4 +188,32 @@ namespace Lskj.Control.BrowserSetting
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过 CefBrowser 获取所在��
|
||||
/// 通过 CefBrowser 获取所在的 WinForms 窗口
|
||||
/// </summary>
|
||||
public static Form GetParentForm(CefBrowser browser,out string ModuleCode)
|
||||
{
|
||||
ModuleCode = "";
|
||||
try
|
||||
{
|
||||
if (browser == null) return null;
|
||||
IntPtr browserHandle = browser.GetHost().GetWindowHandle();
|
||||
if (browserHandle == IntPtr.Zero) return null;
|
||||
IntPtr parentHandle = GetParent(browserHandle);
|
||||
if (parentHandle == IntPtr.Zero) return null;
|
||||
System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle(parentHandle);
|
||||
|
||||
if (control != null && control.Parent != null && control.Parent.Parent != null)
|
||||
{
|
||||
ModuleCode = (control.Parent.Parent).Tag + "";
|
||||
}
|
||||
|
||||
return control as Form;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user