?
Solved

Refreshing AxWebBrowser in background while other browser is displayed

Posted on 2005-04-14
8
Medium Priority
?
861 Views
Last Modified: 2007-12-19
I have a simple program that navigates 4 browser windows to 4 different web sites and then after my timer elapses at 20 seconds the browser 1 will hide then 2 will show all the way through the 4 windows looping.  Problem is that I am sending a refresh command to the browser while it is in the background and the browser window does not refresh until it is visible again.  I have tried both AxWebBrowser.Refresh() and AxWebBrowser.Refresh2().  Refresh doesn't seem to work at all and Refresh2 will work but only when the browser is visible.  Here is code below.


 Private Sub Timer1_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
        On Error Resume Next

        Static intBrowserID As Integer = 0

        Select Case intBrowserID
            Case 0
                AxWebBrowser1.Visible = True
                AxWebBrowser2.Visible = False
                'AxWebBrowser2.Refresh2()
                AxWebBrowser3.Visible = False
                AxWebBrowser4.Visible = False
                AxWebBrowser4.Refresh2()
            Case 1
                AxWebBrowser1.Visible = False
                AxWebBrowser1.Refresh2()
                AxWebBrowser2.Visible = True
                AxWebBrowser3.Visible = False
                AxWebBrowser4.Visible = False
            Case 2
                AxWebBrowser1.Visible = False
                AxWebBrowser2.Visible = False
                AxWebBrowser2.Refresh2()
                AxWebBrowser3.Visible = True
                AxWebBrowser4.Visible = False
            Case 3
                AxWebBrowser1.Visible = False
                AxWebBrowser2.Visible = False
                AxWebBrowser3.Visible = False
                AxWebBrowser3.Refresh2()
                AxWebBrowser4.Visible = True
        End Select
        intBrowserID += 1
        If intBrowserID > 3 Then
            intBrowserID = 0
        End If

    End Sub
0
Comment
Question by:kevandju
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13784422
If refresh isn't working, what about navigating to it's own URL... soemthing like

AxWebBrowser.Navigate2(AxWebBrowser.LocationURL)

==========

if it doesn't register since it's the same URL, navigate away, and then back again

Dim locURL as string = AxWebBrowser.LocationURL
AxWebBrowser.Navigate2("")
AxWebBrowser.Navigate2(locUR)


0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13784426
sorry, it should have read:

Dim locURL as string = AxWebBrowser.LocationURL
AxWebBrowser.Navigate2("")
AxWebBrowser.Navigate2(locURL)
0
 

Author Comment

by:kevandju
ID: 13784525
I'm trying it right now.  What exactly is the difference between .Navigate and .Navigate2?  I don't get what the 2 means.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 32

Expert Comment

by:Erick37
ID: 13784532
It may be related to this bug:

BUG: DocumentComplete Does Not Fire When WebBrowser Is Not Visible
http://support.microsoft.com/default.aspx?scid=kb;en-us;259935

Microsoft recommends not using an invisible WebBrowser, but instead position the WebBrowser control off-screen so it is not in view.
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13784553
I believe navigate2 was an updated version of Navigate... but the old one was left in there for compatibility
0
 
LVL 3

Accepted Solution

by:
angelfeijoo earned 1400 total points
ID: 13784995
Kevandju,

"Refresh" is a method all controls have to redraw themselves to the screen. That has nothing to do with re-loading a website.

"Refresh2" reloads the website. As you found it seems that only actually starts reloading when the browser becomes visible again, thus is not helping your logic.

Assuming that all your browsers were one over the other so they show in the same place, do this:

        ....
        Select Case intBrowserID
            Case 0
                AxWebBrowser1.BringToFront
                AxWebBrowser4.Refresh2()
            Case 1
                AxWebBrowser1.Refresh2()
                AxWebBrowser2.BringToFront
            Case 2
                AxWebBrowser2.Refresh2()
                AxWebBrowser3.BringToFront
            Case 3
                AxWebBrowser3.Refresh2()
                AxWebBrowser4.BringToFront
        End Select
        ...
       
0
 

Author Comment

by:kevandju
ID: 13785147
That works perfectly angelfeijoo.  I already had the 4 browser windows overlayed.  I just didn't know about the bringtofront command.  Thanks for the insight!!
0
 
LVL 3

Expert Comment

by:angelfeijoo
ID: 13785189
You're welcome!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question