| |

VerySource

 Forgot password?
 Register
Search
View: 1601|Reply: 11

How to make progress bar sync with page load (C #)? ?

[Copy link]

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-19 07:20:01
| Show all posts |Read mode
Recently made a browser

I want to make a progress bar like the bottom left corner of IE and other browsers, but I don't know how to associate the progressbar with my webbrowser to achieve the purpose of synchronizing the page loading and the progress bar.

Please say more in detail ~~ Thank you all in advance ~
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-1-26 20:54:01
| Show all posts
Establish a delegation:
   _axWebBrowser.ProgressChange + = new
                AxSHDocVw.DWebBrowserEvents2_ProgressChangeEventHandler (
                this.mainBrowser_ProgressChange);
Reprocessing:
     private void mainBrowser_ProgressChange (object sender, AxSHDocVw.DWebBrowserEvents2_ProgressChangeEvent e)
        {// Handle progress bar events
            AxSHDocVw.AxWebBrowser axWebBrowser1 = (AxSHDocVw.AxWebBrowser) sender;
            HE_WebBrowserTag _HE_WebBrowserTag = (HE_WebBrowserTag) axWebBrowser1.Tag;

            // If the current page does not match the current webbrowser, then discard it
            if (_HE_WebBrowserTag._TabIndex! = this.MainTabCtrl.SelectedIndex) {return;}

            processBar.Visible = true;
            if ((e.progress> 0)&&(e.progressMax> 0))
            {
                processBar.Maximum = e.progressMax;
                processBar.Step = e.progress;
                processBar.PerformStep ();
            }
            else if (axWebBrowser1.ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
            {
                processBar.Value = 0;
                processBar.Visible = false;
            }
        }
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-12 15:00:01
| Show all posts
Good, I even try it first.
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-14 11:15:02
| Show all posts
up
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-17 17:15:01
| Show all posts
Can you explain the principle
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-17 17:45:01
| Show all posts
Still don't quite understand ~
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-17 20:45:02
| Show all posts
This is equivalent to trying to reference the browser's wait function
Reply

Use magic Report

0

Threads

23

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-2-23 12:45:02
| Show all posts
VS2005 uses webBrowser code:
private void Form1_Load (object sender, EventArgs e)
        {
            Uri url = new Uri ("http://www.163.com");
            webBrowser1.Url = url;
            webBrowser1.ProgressChanged + = new WebBrowserProgressChangedEventHandler (webBrowser1_ProgressChanged);
        }

        private void webBrowser1_ProgressChanged (object sender, WebBrowserProgressChangedEventArgs e)
        {
            
            processBar.Visible = true;
            if ((e.CurrentProgress> 0)&&(e.MaximumProgress> 0))
            {
                processBar.Maximum = Convert.ToInt32 (e.MaximumProgress);
                processBar.Step = Convert.ToInt32 (e.CurrentProgress);
                processBar.PerformStep ();
            }
            else if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
            {
                processBar.Value = 0;
                processBar.Visible = false;
            }
        }
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-3-11 22:45:01
| Show all posts
Can you talk about his specific implementation process ~
There are many details that are not well understood ~~
Reply

Use magic Report

2

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-14 10:30:02
| Show all posts
Jack it up yourself!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list