Awesomium Popup - ShowCreatedWebView示例

Mar*_*ujo 6 c# popupwindow winforms c#-4.0 awesomium

C# Windows Forms在Visual Studio 2012中使用Awesomium 1.7.4.2 .我无法通过单击超链接打开弹出窗口.

我有一个WebControl表格并ShowCreatedWebView正在捕捉事件,但在里面我不知道如何打开一个新窗口弹出子项将数据传递给POST.

我知道我必须使用ShowCreatedWebView并尝试使用SDK示例失败:

http://docs.awesomium.net/?tc=E_Awesomium_Core_IWebView_ShowCreatedWebView

它只是不起作用!

谁能举个例子C# windows forms

谁能帮我?

voy*_*tek 6

请记住添加target="_blank"您的超链接:

<a id="foo" href="http://...." target="_blank">Test link</a>
Run Code Online (Sandbox Code Playgroud)

然后你需要的只是捕获ShowCreatedWebView事件,如下所示:

webControl1.ShowCreatedWebView += OnShowNewView;

internal static void OnShowNewView( object sender, ShowCreatedWebViewEventArgs e )
{
    // Your link is in e.TargetURL
    // You can handle it like in docs you've mentioned 
}
Run Code Online (Sandbox Code Playgroud)

您可以使用外部浏览器打开它,如下所示:

System.Diagnostics.Process.Start(e.TargetURL.ToString());
Run Code Online (Sandbox Code Playgroud)

你可以像在Awesomium docs中那样处理它:

    internal static void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e)
    {
        WebControl webControl = sender as WebControl;

        if (webControl == null)
            return;

        if (!webControl.IsLive)
            return;

        ChildWindow newWindow = new ChildWindow();

        if (e.IsPopup && !e.IsUserSpecsOnly)
        {
            Int32Rect screenRect = e.Specs.InitialPosition.GetInt32Rect();

            newWindow.NativeView = e.NewViewInstance;
            newWindow.ShowInTaskbar = false;
            newWindow.WindowStyle = System.Windows.WindowStyle.ToolWindow;
            newWindow.ResizeMode = e.Specs.Resizable ? ResizeMode.CanResizeWithGrip : ResizeMode.NoResize;

            if ((screenRect.Width > 0) && (screenRect.Height > 0))
            {
                newWindow.Width = screenRect.Width;
                newWindow.Height = screenRect.Height;
            }
            newWindow.Show();
            if ((screenRect.Y > 0) && (screenRect.X > 0))
            {
                newWindow.Top = screenRect.Y;
                newWindow.Left = screenRect.X;
            }
        }
        else if (e.IsWindowOpen || e.IsPost)
        {
            newWindow.NativeView = e.NewViewInstance;
            newWindow.Show();
        }
        else
        {
            e.Cancel = true;
            newWindow.Source = e.TargetURL;
            newWindow.Show();
        }
    }
Run Code Online (Sandbox Code Playgroud)