Ejemplo n.º 1
0
        private void Browser_OnDocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            if (sender == null)
            {
                return;
            }
            AxWebBrowser browser = sender as AxWebBrowser;

            if (browser == null)
            {
                return;
            }

            mshtml.IHTMLDocument2 document = browser.Document as mshtml.IHTMLDocument2;
            string title = document.title;

            if (title == string.Empty)
            {
                this.Text = "[Empty]";
            }
            else
            {
                this.Text = title;
            }

            if (OnDocumentComplete != null)
            {
                OnDocumentComplete(this);
            }
        }
    static void Main(string[] args)
    {
        URLSecurityZoneAPI.InternetSetFeatureEnabled(URLSecurityZoneAPI.InternetFeaturelist.DISABLE_NAVIGATION_SOUNDS, URLSecurityZoneAPI.SetFeatureOn.PROCESS, true);

        var browser  = new AxWebBrowser();
        var hostForm = new Form();

        hostForm.Width         = 0;
        hostForm.Height        = 0;
        hostForm.ShowInTaskbar = false;
        hostForm.ControlBox    = false;
        hostForm.ShowIcon      = false;
        hostForm.MinimizeBox   = false;
        hostForm.MaximizeBox   = false;
        hostForm.Controls.Add(browser);
        hostForm.Show();
        hostForm.Hide();

        browser.DocumentComplete += delegate(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            var doc = (IHTMLDocument3)browser.Document;
            Console.WriteLine(doc.documentElement.innerHTML);
        };

        browser.Navigate("www.google.com");

        while (true)
        {
            System.Windows.Forms.Application.DoEvents();
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            ResourceManager resources = new ResourceManager(typeof(MpeHelpBrowser));

            browser = new AxWebBrowser();
            ((ISupportInitialize)(browser)).BeginInit();
            SuspendLayout();
            //
            // browser
            //
            browser.Dock     = DockStyle.Fill;
            browser.Enabled  = true;
            browser.Location = new Point(0, 0);
            browser.OcxState = ((AxHost.State)(resources.GetObject("browser.OcxState")));
            browser.Size     = new Size(368, 224);
            browser.TabIndex = 0;
            //
            // MpeHelpBrowser
            //
            Controls.Add(browser);
            Name = "MpeHelpBrowser";
            Size = new Size(368, 224);
            ((ISupportInitialize)(browser)).EndInit();
            ResumeLayout(false);
        }
Ejemplo n.º 4
0
 public IECaptForm(string url, string file, int minWidth, int delay, AxWebBrowser wb)
 {
     mURL            = url;
     mFile           = file;
     mMinWidth       = minWidth;
     mTimer.Interval = delay;
     mTimer.Tick    += new EventHandler(mTimer_Tick);
     mWb             = wb;
 }
        public DocHostUIHandler(AxWebBrowser hostControl)
        {
            if ((hostControl == null) || (hostControl.IsHandleCreated == false))
            {
                throw new ArgumentNullException("hostControl");
            }

            this.hostControl = hostControl;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initialize a PrivateBrowserCommand
        /// </summary>
        /// <param name="browser">reference to underlying browser control</param>
        /// <param name="cmdID">unique ID of command</param>
        public PrivateBrowserCommand(AxWebBrowser browser, uint cmdID)
            : base(browser)
        {
            // make sure the cmdID is valid
            Debug.Assert(cmdID >= PrivateCommandMin && cmdID <= PrivateCommandMax,
                         "Invalid private command ID");

            // save the command ID
            m_cmdID = cmdID;
        }
Ejemplo n.º 7
0
        public void SwitchLayoutEngine(String id)
        {
            AxHost host = null;
            String url  = "about:blank";

            switch (id)
            {
            case "trident":
                if (gecko != null)
                {
                    url = gecko.LocationURL;
                    this.Controls.Remove(gecko as AxHost);
                    gecko = null;
                }

                if (trident == null)
                {
                    trident = new AxWebBrowser();
                    host    = trident as AxHost;
                }

                break;

            default:
                if (trident != null)
                {
                    url = trident.LocationURL;
                    this.Controls.Remove(trident as AxHost);
                    trident = null;
                }

                if (gecko == null)
                {
                    gecko = new AxMozillaBrowser();
                    host  = gecko as AxHost;
                }
                break;
            }

            if (host != null)
            {
                host.BeginInit();
                host.TabIndex = 1;
                host.Dock     = DockStyle.Fill;
                host.EndInit();
                this.Controls.Add(host);
            }

            // Add appropriate content area listeners
            AddListeners();

            ServiceManager.Preferences.SetStringPref("browser.layoutengine", id);

            LoadURL(url, false);
        }
Ejemplo n.º 8
0
        private void AxWebBrowser_DocumentComplete(object sender, Netron.Neon.DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            if (sender == null)
            {
                return;
            }
            AxWebBrowser browser = sender as AxWebBrowser;

            if (browser == null)
            {
                return;
            }
            browser.ScriptObject = this;
//			mshtml.IHTMLDocument2 document =  browser.Document as mshtml.IHTMLDocument2;
//			string title = document.title;
        }
    private void IE_NavigateError(object sender, DWebBrowserEvents2_NavigateErrorEvent e)
    {
        AxWebBrowser wb = (AxWebBrowser)sender;

        // Ignore errors for embedded documents
        if (wb.Application != e.pDisp)
        {
            return;
        }

        // If we get here, the main document cannot be navigated
        // to meaning there is nothing to draw, so we just croak.
        Console.Error.WriteLine("Failed to navigate to {0} (0x{1:X08})", e.uRL, e.statusCode);
        ReportCapture(null);

        wb.Dispose();
    }
Ejemplo n.º 10
0
        public void InitializeComponent()
        {
            this.WebBrowser = new AxWebBrowser();
            this.WebBrowser.BeginInit();
            this.SuspendLayout();

            this.Text        = "HTML UI Demo";
            this.Size        = new Size(563, 474);
            this.MinimumSize = new Size(563, 474);
            this.Font        = new Font("Tahoma", 8);

            this.WebBrowser.Dock = DockStyle.Fill;

            this.Controls.Add(this.WebBrowser);
            this.ResumeLayout(false);
            this.WebBrowser.EndInit();
        }
Ejemplo n.º 11
0
        public void InitializeWebBrowser()
        {
            // Create a new instance of the web browser control
            Browser = new AxWebBrowser();

            // Begin initializing the control
            Browser.BeginInit();

            // Add the control to the main form and dock it inside
            // of a panel
            this.Controls.Add(Browser);
            Browser.Parent = BrowserContainer;
            Browser.Dock   = DockStyle.Fill;

            // Finish initializing the ActiveX
            Browser.EndInit();
        }
    public void CapturePage(string url)
    {
        this.url = url;

        mWb = new AxWebBrowser();

        mWb.BeginInit();
        mWb.Parent = new Form();
        mWb.EndInit();

        // Set the initial dimensions of the browser's client area.
        mWb.SetBounds(0, 0, width, height);

        object oBlank = "about:blank";
        object oURL   = url;
        object oNull  = String.Empty;

        // Internet Explorer should show no dialog boxes; this does not dis-
        // able script debugging however, I am not aware of a method to dis-
        // able that, other than manual configuration in he Internet Settings
        // or perhaps the registry.
        mWb.Silent = true;

        // The custom UI handler can only be registered on a document, so we
        // navigate to about:blank as a first step, then register the handler.
        mWb.Navigate2(ref oBlank, ref oNull, ref oNull, ref oNull, ref oNull);

        ICustomDoc cdoc = mWb.Document as ICustomDoc;

        cdoc.SetUIHandler(new IECaptUIHandler());

        // Register a document complete handler. It will be called whenever a
        // document completes loading, including embedded documents and the
        // initial about:blank document.
        mWb.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete);

        // Register an error handler. If the main document cannot be loaded,
        // the document complete event will not fire, so we have to listen to
        // this and shut the application down in case of a fatal error.
        mWb.NavigateError += new DWebBrowserEvents2_NavigateErrorEventHandler(IE_NavigateError);

        // Now navigate to the final destination.
        mWb.Navigate2(ref oURL, ref oNull, ref oNull, ref oNull, ref oNull);
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Helper function to initialize the browser and add it to the
        /// client area of the UserControl (it fills the entire area)
        /// </summary>
        private void InitializeBrowser()
        {
            // create browser instance
            m_browser = new AxWebBrowser();

            // begin initialization
            SuspendLayout();
            m_browser.BeginInit();

            // add browser to out client area
            m_browser.Enabled  = true;
            m_browser.Dock     = DockStyle.Fill;
            m_browser.TabIndex = 0;
            Controls.Add(m_browser);

            // end initialization
            m_browser.EndInit();
            ResumeLayout(false);
        }
Ejemplo n.º 14
0
    public static Result StartBrowse(string url)
    {
        var validUri = (url.Contains("http://") ? url : "http://" + url);

        wBrowser = new AxWebBrowser();
        System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AxWebBrowser));

        ((ISupportInitialize)(wBrowser)).BeginInit();
        wBrowser.OcxState          = ((AxHost.State)(resources.GetObject("wBrowser.OcxState")));
        wBrowser.NewWindow2       += wBrowser_NewWindow2;
        wBrowser.NewWindow3       += wBrowser_NewWindow3;
        wBrowser.DocumentComplete += wBrowser_DocumentComplete;
        wBrowser.DownloadComplete += wBrowser_DownloadComplete;
        if (string.IsNullOrEmpty(html) || validUri != url)
        {
            object empty = System.Reflection.Missing.Value;
            wBrowser.Silent = true;
            wBrowser.Navigate(validUri, ref empty, ref empty, ref empty, ref empty);
        }
        return(null);
    }
    private void IE_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
    {
        AxWebBrowser wb = (AxWebBrowser)sender;

        // Skip document complete event for embedded frames.
        if (wb.Application != e.pDisp)
        {
            return;
        }

        // Skip the initial about:blank document; this is not necessarily
        // the best thing to do, e.g. if the requested page is about:blank
        // or redirects to it, we might never exit. This could be avoided
        // by remembering whether we saw the first document complete event.
        if (e.uRL.Equals("about:blank"))
        {
            return;
        }

        mTimer.Start();
    }
Ejemplo n.º 16
0
        private void InitializeComponent()
        {
            ComponentResourceManager resources = new ComponentResourceManager(typeof(FrmWebDialog));

            this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();
            this.axWebBrowser1.BeginInit();
            base.SuspendLayout();
            this.axWebBrowser1.Dock     = DockStyle.Fill;
            this.axWebBrowser1.Enabled  = true;
            this.axWebBrowser1.Location = new Point(0, 0);
            this.axWebBrowser1.OcxState = (AxHost.State)resources.GetObject("axWebBrowser1.OcxState");
            this.axWebBrowser1.Size     = new Size(0x35e, 0x23f);
            this.axWebBrowser1.TabIndex = 0;
            base.AutoScaleDimensions    = new SizeF(6f, 12f);
            base.AutoScaleMode          = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize             = new Size(0x35e, 0x23f);
            base.Controls.Add(this.axWebBrowser1);
            base.Name  = "FrmWebDialog";
            this.Text  = "FrmWebDialog";
            base.Load += new EventHandler(this.FrmWebDialog_Load);
            this.axWebBrowser1.EndInit();
            base.ResumeLayout(false);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(XmlViewer));
     this.axWebBrowser = new AxSHDocVw.AxWebBrowser();
     this.grpViewer    = new System.Windows.Forms.GroupBox();
     ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser)).BeginInit();
     this.grpViewer.SuspendLayout();
     this.SuspendLayout();
     //
     // axWebBrowser
     //
     this.axWebBrowser.ContainingControl = this;
     this.axWebBrowser.Enabled           = true;
     this.axWebBrowser.Location          = new System.Drawing.Point(16, 24);
     this.axWebBrowser.OcxState          = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser.OcxState")));
     this.axWebBrowser.Size     = new System.Drawing.Size(616, 376);
     this.axWebBrowser.TabIndex = 2;
     //
     // grpViewer
     //
     this.grpViewer.Controls.Add(this.axWebBrowser);
     this.grpViewer.Location = new System.Drawing.Point(8, 16);
     this.grpViewer.Name     = "grpViewer";
     this.grpViewer.Size     = new System.Drawing.Size(648, 424);
     this.grpViewer.TabIndex = 3;
     this.grpViewer.TabStop  = false;
     this.grpViewer.Text     = "grpViewer";
     //
     // XmlViewer
     //
     this.Controls.Add(this.grpViewer);
     this.Name = "XmlViewer";
     this.Size = new System.Drawing.Size(664, 456);
     ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser)).EndInit();
     this.grpViewer.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Ejemplo n.º 18
0
        private void InitializeComponent()
        {
            ResourceManager manager = new ResourceManager(typeof(PrintColumnSelection));

            this.label1             = new Label();
            this.AllColumnsList     = new ListBox();
            this.SelectedColumnList = new ListBox();
            this.label2             = new Label();
            this.PPreview           = new Button();
            this.EditPrint          = new Button();
            this.PrintTemplateList  = new ListBox();
            this.label3             = new Label();
            this.label4             = new Label();
            this.templateBrowser    = new AxWebBrowser();
            this.templateBrowser.BeginInit();
            base.SuspendLayout();
            this.label1.Font                       = new Font("Arial", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.label1.Location                   = new Point(0, 8);
            this.label1.Name                       = "label1";
            this.label1.Size                       = new Size(120, 0x18);
            this.label1.TabIndex                   = 0;
            this.label1.Text                       = "         All Columns";
            this.AllColumnsList.Font               = new Font("Arial", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.AllColumnsList.ItemHeight         = 14;
            this.AllColumnsList.Location           = new Point(8, 0x20);
            this.AllColumnsList.Name               = "AllColumnsList";
            this.AllColumnsList.Size               = new Size(0x88, 0x1a8);
            this.AllColumnsList.TabIndex           = 1;
            this.AllColumnsList.DoubleClick       += new EventHandler(this.AllColumnsList_DoubleClick);
            this.SelectedColumnList.Font           = new Font("Arial", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.SelectedColumnList.ItemHeight     = 14;
            this.SelectedColumnList.Location       = new Point(0x98, 0x20);
            this.SelectedColumnList.Name           = "SelectedColumnList";
            this.SelectedColumnList.Size           = new Size(0x88, 0x1a8);
            this.SelectedColumnList.TabIndex       = 3;
            this.SelectedColumnList.DoubleClick   += new EventHandler(this.SelectedColumnList_DoubleClick);
            this.label2.Font                       = new Font("Arial", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.label2.Location                   = new Point(160, 8);
            this.label2.Name                       = "label2";
            this.label2.Size                       = new Size(120, 0x18);
            this.label2.TabIndex                   = 2;
            this.label2.Text                       = "   Selected Columns";
            this.PPreview.Location                 = new Point(0x98, 0x1d0);
            this.PPreview.Name                     = "PPreview";
            this.PPreview.Size                     = new Size(0x90, 0x20);
            this.PPreview.TabIndex                 = 4;
            this.PPreview.Text                     = "Print Preview..";
            this.PPreview.Click                   += new EventHandler(this.PPreview_Click);
            this.EditPrint.Location                = new Point(8, 0x1d0);
            this.EditPrint.Name                    = "EditPrint";
            this.EditPrint.Size                    = new Size(0x88, 0x20);
            this.EditPrint.TabIndex                = 5;
            this.EditPrint.Text                    = "Preview";
            this.EditPrint.Click                  += new EventHandler(this.EditPrint_Click);
            this.PrintTemplateList.Font            = new Font("Arial", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.PrintTemplateList.ItemHeight      = 14;
            this.PrintTemplateList.Location        = new Point(0x300, 0x20);
            this.PrintTemplateList.Name            = "PrintTemplateList";
            this.PrintTemplateList.Size            = new Size(120, 0x1a8);
            this.PrintTemplateList.TabIndex        = 6;
            this.label3.Font                       = new Font("Arial", 8.25f, FontStyle.Bold);
            this.label3.Location                   = new Point(0x300, 8);
            this.label3.Name                       = "label3";
            this.label3.Size                       = new Size(0x88, 0x10);
            this.label3.TabIndex                   = 7;
            this.label3.Text                       = "Choose Template..";
            this.label4.Font                       = new Font("Arial", 8.25f, FontStyle.Bold);
            this.label4.Location                   = new Point(320, 8);
            this.label4.Name                       = "label4";
            this.label4.Size                       = new Size(0x98, 0x10);
            this.label4.TabIndex                   = 9;
            this.label4.Text                       = "Print template preview";
            this.templateBrowser.Enabled           = true;
            this.templateBrowser.Location          = new Point(0x130, 0x20);
            this.templateBrowser.OcxState          = (AxHost.State)manager.GetObject("templateBrowser.OcxState");
            this.templateBrowser.Size              = new Size(0x1c8, 0x1a8);
            this.templateBrowser.TabIndex          = 10;
            this.templateBrowser.DocumentComplete += new AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(this.templateBrowser_DocumentComplete);
            this.AutoScaleBaseSize                 = new Size(5, 13);
            base.ClientSize = new Size(0x388, 0x1f5);
            base.Controls.Add(this.templateBrowser);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.PrintTemplateList);
            base.Controls.Add(this.EditPrint);
            base.Controls.Add(this.PPreview);
            base.Controls.Add(this.SelectedColumnList);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.AllColumnsList);
            base.Controls.Add(this.label1);
            base.MaximizeBox   = false;
            base.MinimizeBox   = false;
            base.Name          = "PrintColumnSelection";
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text          = "Select Columns";
            base.Load         += new EventHandler(this.PrintColumnSelection_Load);
            this.templateBrowser.EndInit();
            base.ResumeLayout(false);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Initialize a NewWindowBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public NewWindowBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initialize a DirectInvokeBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public DirectInvokeBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initialize a BrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public ExplorerBrowserCommand(AxWebBrowser browser)
 {
     Browser = browser;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initialize a NativeBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 /// <param name="cmdID">unique ID of command</param>
 public StandardBrowserCommand(AxWebBrowser browser, OLECMDID cmdID)
     : base(browser)
 {
     m_cmdID = cmdID;
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Initialize an LanguagesBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public LanguagesBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Initialize an OrganizeFavoritesBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public OrganizeFavoritesBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Initialize an AddFavoriteBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public AddFavoriteBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Initialize a ShellUIHelperBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public ShellUIHelperBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Initialize a StopBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public StopBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Initialize a GoForwardBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public GoForwardBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Initialize a GoSearchBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public GoSearchBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Initialize a GoHomeBrowserCommand
 /// </summary>
 /// <param name="browser">reference to underlying browser control</param>
 public GoHomeBrowserCommand(AxWebBrowser browser)
     : base(browser)
 {
 }