how to use Mozilla ActiveX Control (axMozillaBrows

2019-09-14 04:40发布

i am trying to reload a web page 3 times using "axMozillaBrowser1(Mozilla ActiveX Control)" but axMozillaBrowser1 control is not loading web page and it's waiting courser is blinking regular but browser control is not loading web page.

Please tell me how to use axMozillaBrowser1 control properly. Thanx in advance.

this is my program code:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        progressBar1.Maximum = 3;
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        do
        {
            axMozillaBrowser1.Navigate(textBox1.Text);
            while(axMozillaBrowser1.ReadyState != MOZILLACONTROLLib.tagREADYSTATE.READYSTATE_COMPLETE)
            {
                Application.DoEvents();
                if (axMozillaBrowser1.ReadyState == MOZILLACONTROLLib.tagREADYSTATE.READYSTATE_COMPLETE)
                { 
                    progressBar1.Value = progressBar1.Value + 1; 
                }
            }
        }while(progressBar1.Value != 3);
    }
}

1条回答
唯我独甜
2楼-- · 2019-09-14 05:03

Why you want to Navigate 3 times ?

But my suggest is :

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        progressBar1.Maximum = 3;
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
             progressBar1.Value = 0; 
            axMozillaBrowser1.Navigate(textBox1.Text);
    }

    private void webBrowser2_Navigated(object sender, WebBrowserNavigatedEventArgs e)
    {
        if ( progressBar1.Value < 3 )
        {
            axMozillaBrowser1.Navigate(textBox1.Text);
            progressBar1.Value = progressBar1.Value + 1; 
        }

    }
}
查看更多
登录 后发表回答