2014-09-17 21 views
6

Sto lavorando con Awesomium 1.7.4.2 con C# Windows Forms in Visual Studio 2012. Non riesco ad aprire una finestra popup facendo clic su un collegamento ipertestuale.Awesomium Popup - ShowCreatedWebView Esempio

Ho un nel modulo e ShowCreatedWebView sto catturando l'evento, ma all'interno non so come aprire una nuova finestra popup figlio che passa i dati a POST.

So che devo usare ShowCreatedWebView e ha cercato senza successo di utilizzare l'esempio SDK:

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

Semplicemente non funziona!

Qualcuno può dare un esempio in C# windows forms?

Qualcuno può aiutarmi?

risposta

6

Ricordarsi di aggiungere target="_blank" nel vostro collegamento ipertestuale:

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

e quindi tutto ciò che serve è quello di catturare ShowCreatedWebView evento, in questo modo:

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 
} 

è possibile aprirlo con il browser esterno, come questo :

Puoi gestirlo come 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(); 
     } 
    }