Awesomium Popup - ShowCreatedWebView Example

I am working with Awesomium 1.7.4.2 with C# Windows Forms in Visual Studio 2012. I cannot open the popup by clicking the hyperlink.

I have a WebControl form in the form and ShowCreatedWebView am capturing an event, but inside I don’t know how to open the popup child window of a new window by passing POST data.

I know I have to use ShowCreatedWebView and tried unsuccessfully to use the sample SDK:

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

It just doesn't work!

Can someone give an example in C# Windows Forms ?

Can anybody help me?

+6
source share
1 answer

Remember to add target="_blank" to your hyperlink:

 <a id="foo" href="http://...." target="_blank">Test link</a> 

and then all you need is to capture the ShowCreatedWebView event, for example:

 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 } 

You can open it using an external browser, for example:

 System.Diagnostics.Process.Start(e.TargetURL.ToString()); 

You can handle it as in 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(); } } 
+6
source

Source: https://habr.com/ru/post/975422/


All Articles