|
-
Feb 28th, 2005, 10:18 AM
#1
Thread Starter
Junior Member
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
-
Feb 28th, 2005, 10:20 AM
#2
Re: WebBrowser - attendere caricamento
Can anyone translate this please. Thanks.
-
Feb 28th, 2005, 10:40 AM
#3
Thread Starter
Junior Member
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
-
Feb 28th, 2005, 11:09 AM
#4
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:
Option Explicit
Private Sub Form_Load()
With List1
.AddItem "http://www.microsoft.it"
.AddItem "http://www.vbforums.com"
.AddItem "http://www.ansa.it"
.AddItem "http://www.gazzetta.it"
End With
With Timer1
.Interval = 10000 '10 seconds
.Enabled = True
End With
WebBrowser1.Navigate List1.List(0)
End Sub
Private Sub Timer1_Timer()
Static i%
i = i + 1
WebBrowser1.Navigate List1.List(i)
If i > List1.ListCount - 1 Then i = 0
End Sub
-
Feb 28th, 2005, 11:26 AM
#5
Thread Starter
Junior Member
Re: WebBrowser - attendere caricamento
-
Feb 28th, 2005, 11:50 AM
#6
Thread Starter
Junior Member
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
-
Feb 28th, 2005, 11:53 AM
#7
Re: WebBrowser - attendere caricamento
Increase interval to say 1 minute:
VB Code:
With Timer1
.Interval = [b]60000 '1 minute[/b]
.Enabled = True
End With
-
Mar 2nd, 2005, 03:56 AM
#8
Thread Starter
Junior Member
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
-
Mar 2nd, 2005, 09:30 AM
#9
Re: WebBrowser - attendere caricamento
Yes, there is a way - just trap NavigateComplete event:
VB Code:
Option Explicit
Private Sub Form_Load()
With List1
.AddItem "http://www.microsoft.it"
.AddItem "http://www.vbforums.com"
.AddItem "http://www.ansa.it"
.AddItem "http://www.gazzetta.it"
End With
With Timer1
.Interval = 60000 '1 minute
.Enabled = False
End With
WebBrowser1.Navigate List1.List(0)
End Sub
Private Sub Timer1_Timer()
Static i%
i = i + 1
WebBrowser1.Navigate List1.List(i)
Timer1.Enabled = False
If i > List1.ListCount - 1 Then i = 0
End Sub
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Timer1.Enabled = True
End Sub
-
Mar 2nd, 2005, 10:24 AM
#10
Thread Starter
Junior Member
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 ?
-
Mar 2nd, 2005, 10:58 AM
#11
Re: WebBrowser - attendere caricamento
NO, just use what I posted and it should be enough to do what you want.
Regards.
-
Mar 2nd, 2005, 11:13 AM
#12
Thread Starter
Junior Member
Re: WebBrowser - attendere caricamento
I have tried but the time not start when the page is finished to load....
-
Mar 2nd, 2005, 11:32 AM
#13
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.
-
Mar 2nd, 2005, 11:46 AM
#14
Thread Starter
Junior Member
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
-
Mar 2nd, 2005, 11:50 AM
#15
Re: WebBrowser - attendere caricamento
I am trying to help you, however I'm not sure at this moment what the problem is anymore ... Sorry.
-
Mar 3rd, 2005, 04:38 AM
#16
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|