I'm working with Awesomium 1.7.4.2 with C# Windows Forms
in Visual Studio 2012. I'm not able to open a popup window by click of a hyperlink.
I have a WebControl
in form and ShowCreatedWebView
am capturing the event, but inside I do not know how to open a new window popup child passing the data to POST.
I know I must use ShowCreatedWebView
and tried unsuccessfully to use the SDK sample:
http://docs.awesomium.net/?tc=E_Awesomium_Core_IWebView_ShowCreatedWebView
It just does not work!
Can anyone give an example in C# windows forms
?
Can anyone help me?
Remember to add target="_blank"
in your hyperlink:
<a id="foo" href="http://...." target="_blank">Test link</a>
and then all you need is to capture ShowCreatedWebView
event, like this:
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 with external browser, like this:
System.Diagnostics.Process.Start(e.TargetURL.ToString());
You can handle it like 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();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With