Results 1 to 16 of 16

Thread: WebBrowser - attendere caricamento

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    WebBrowser - attendere caricamento

    Ciao a tutti,

    sto utilizzando un controllo webbrowser per visualizzare in un form un insieme di pagine web

    Vorrei che ogni pagina mi rimanesse fissa pe run tot di secondi ( supponiamo 10 ) dopo essere stata caricata completamente.

    Il codice che utilizzo è il seguente :

    webBr1.Navigate "http://news.google.it/nwshp?hl=it&gl=it"

    Do While webBr1.ReadyState <> READYSTATE_COMPLETE
    DoEvents
    Loop

    t1 = Timer

    Do While Timer < t1 + 10
    DoEvents
    Loop

    webBr1.Navigate "http://www.ansa.it"
    .....
    webBr1.Navigate "http://www.gazzetta.it"
    .....



    Evidentemente sto fraintentendo il concetto di doevents perchè così come è il mio codice la pagina mi viene visualizzata dopo 10 secondi e subito sopo viene visualizzata la seconda e così via...

    Qualcuno mi può aiutare a capire meglio ?

    Grazie

    Antonella


  2. #2

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    Sorry, I try to translate...

    I have a pgm that use webBrowser control to load some pages Internet...

    I want that the page stay loaded for a time ( for example 10 seconds) and then I load another page..

    My code is:

    webBr1.Navigate "http://news.google.it/nwshp?hl=it&gl=it"

    Do While webBr1.ReadyState <> READYSTATE_COMPLETE
    DoEvents
    Loop

    t1 = Timer

    Do While Timer < t1 + 10
    DoEvents
    Loop

    webBr1.Navigate "http://www.ansa.it"
    .....
    webBr1.Navigate "http://www.gazzetta.it"
    .....


    but in this case the page is loaded only after 10 second and then the other pages without attend 10 second...

    where I wrong ?

    Excuse me for my bad english...

    Thanks

    Antonella

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: WebBrowser - attendere caricamento

    You may use listbox loaded with all addresses so you can iterate through each (to run this sample you'll need a Listbox, WebBrowser and Timer controls):
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     With List1
    5.         .AddItem "http://www.microsoft.it"
    6.         .AddItem "http://www.vbforums.com"
    7.         .AddItem "http://www.ansa.it"
    8.         .AddItem "http://www.gazzetta.it"
    9.     End With
    10.     With Timer1
    11.         .Interval = 10000 '10 seconds
    12.         .Enabled = True
    13.     End With
    14.     WebBrowser1.Navigate List1.List(0)
    15. End Sub
    16.  
    17. Private Sub Timer1_Timer()
    18. Static i%
    19.  
    20.     i = i + 1
    21.     WebBrowser1.Navigate List1.List(i)
    22.     If i > List1.ListCount - 1 Then i = 0
    23.  
    24. End Sub

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    I try...

    Thanks

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    it's ok only a little....

    the time "10 second" start when I begin to load the page and so some page ( if the connection is slowly) stay on video only 1 or 2 second

    how I must do ?

    Thanks

  7. #7

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    thanks
    but in this mode the time on video for each page is various...
    it isn't a way for start the time only when the page is loaded completely ?

    Antonella

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: WebBrowser - attendere caricamento

    Yes, there is a way - just trap NavigateComplete event:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     With List1
    5.         .AddItem "http://www.microsoft.it"
    6.         .AddItem "http://www.vbforums.com"
    7.         .AddItem "http://www.ansa.it"
    8.         .AddItem "http://www.gazzetta.it"
    9.     End With
    10.     With Timer1
    11.         .Interval = 60000 '1 minute
    12.         .Enabled = False
    13.     End With
    14.     WebBrowser1.Navigate List1.List(0)
    15. End Sub
    16.  
    17. Private Sub Timer1_Timer()
    18. Static i%
    19.  
    20.     i = i + 1
    21.     WebBrowser1.Navigate List1.List(i)
    22.     Timer1.Enabled = False
    23.     If i > List1.ListCount - 1 Then i = 0
    24.  
    25. End Sub
    26.  
    27. Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    28.     Timer1.Enabled = True
    29. End Sub

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    It' ok only add doevents in sub timer

    Private Sub Timer1_Timer()

    i = i + 1
    webBr1.Navigate list1.List(i)

    Do While webBr1.ReadyState <> READYSTATE_COMPLETE
    DoEvents
    Loop


    If i > list1.ListCount - 1 Then i = 0

    End Sub

    it's ok ?

  11. #11

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    I have tried but the time not start when the page is finished to load....

  13. #13
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: WebBrowser - attendere caricamento

    I thought that's how you want it ...
    Also, it could be even better this way: let the page finish loading and then give some time until next page starts ... This way you can prevent previous page from not being completed.

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    Sorry but with my bad english I don't get at explain me...

    I have tried your code but, maybe for my slow connection, the first page is not stay on video for 10 second from the moment that the page is completely loaded...

    I have seen that the navigatecomplete2 event run first that the page is completely load...

    Can you help me ?

    Thanks

  15. #15

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Posts
    17

    Re: WebBrowser - attendere caricamento

    ok,
    thanks for all

    Antonella

    (now I open a new thread for a new question)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width