SHARE
TWEET

Untitled

a guest May 22nd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public sealed class WindowBrowserCreator : nsIWindowCreator2
  2.     {
  3.         public Form m_Parent;
  4.         public TabControl tabControlMain;
  5.         public WindowBrowserCreator(Form p_Parent)
  6.         {
  7.             this.m_Parent = p_Parent;
  8.         }
  9.  
  10.         public nsIWebBrowserChrome CreateChromeWindow(nsIWebBrowserChrome parent, uint chromeFlags)
  11.         {
  12.             bool bCancel = false;
  13.             return CreateWindow(parent, chromeFlags, 0, null, ref bCancel);
  14.         }
  15.  
  16.         public nsIWebBrowserChrome CreateChromeWindow2(nsIWebBrowserChrome parent, uint chromeFlags, uint contextFlags, nsIURI uri, nsITabParent aOpeningTab, ref bool cancel)
  17.         {
  18.             return CreateWindow(parent, chromeFlags, contextFlags, uri, ref cancel);
  19.         }
  20.  
  21.         private nsIWebBrowserChrome CreateWindow(nsIWebBrowserChrome parent, uint chromeFlags, uint contextFlags, nsIURI uri, ref bool cancel)
  22.         {
  23.             GeckoWindowFlags flags = (GeckoWindowFlags)chromeFlags;
  24.  
  25.             if ((flags & GeckoWindowFlags.OpenAsChrome) != 0)
  26.             {
  27.                 // create the child window
  28.                 nsIXULWindow xulChild = AppShellService.CreateTopLevelWindow(null, null, chromeFlags, -1, -1);
  29.  
  30.                 // this little gem allows the GeckoWebBrowser to be properly activated when it gains the focus again
  31.                 if (parent is GeckoWebBrowser && (flags & GeckoWindowFlags.OpenAsDialog) != 0)
  32.                 {
  33.                     EventHandler gotFocus = null;
  34.                     gotFocus = delegate(object sender, EventArgs e)
  35.                     {
  36.                         var br = (sender as GeckoWebBrowser);
  37.                         if (br != null)
  38.                         {
  39.                             br.GotFocus -= gotFocus;
  40.                             br.WebBrowserFocus.Activate();
  41.                         }
  42.  
  43.                     };
  44.                     var parBr = parent as GeckoWebBrowser;
  45.                     parBr.GotFocus += gotFocus;
  46.                 }
  47.  
  48.                 // return the chrome
  49.                 return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);
  50.             }
  51.  
  52.             nsIWebBrowserChrome oBrowser = AddNewTab();
  53.             oBrowser.SetChromeFlagsAttribute(chromeFlags);
  54.             return oBrowser;
  55.         }
  56.  
  57.         public void SetScreenId(uint aScreenId)
  58.         {
  59.             throw new NotImplementedException();
  60.         }
  61.  
  62.         internal nsIWebBrowserChrome AddNewTab()
  63.         {
  64.             GeckoWebBrowser gwBrowserTabPop = new GeckoWebBrowser();
  65.             TabPage oTabPage = new TabPage("New Tab");
  66.             Padding oPadding = oTabPage.Margin; oPadding.All = 0;
  67.             oPadding = oTabPage.Padding; oPadding.All = 0;
  68.             oTabPage.Controls.Add(gwBrowserTabPop);
  69.             gwBrowserTabPop.Dock = DockStyle.Fill;
  70.             tabControlMain.TabPages.Add(oTabPage);
  71.             return gwBrowserTabPop;
  72.         }
  73.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top