Results 1 to 9 of 9

Thread: [RESOLVED] Help with axwebbrowser control

  1. #1

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Resolved [RESOLVED] Help with axwebbrowser control

    Hello everyone,
    Soemone please help me do this...
    I have a list of url's in a listbox.Im trying to make the axwebbrowser navigate to the next item as soon as the document has loaded for one item.
    Ive been trying this,but i dont know,it seems to act so wierd.
    I know how to use the "for loop",but please understand,its not workingg..I trieddd. so,help me
    I just want the axwebbrowser to navigate through all the urls in the listbox one by one and then just stop.

    Im using vs2003 btw

    Thanks a tonne...Thankk youuu
    Godwin

    Help someone else with what someone helped you!

  2. #2
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Help with axwebbrowser control

    Post your code for the for loop. And by not working what do you mean?
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  3. #3

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Help with axwebbrowser control

    Quote Originally Posted by mpdeglau
    Post your code for the for loop. And by not working what do you mean?
    ah! Smart guy

    ok,ill just post the code
    Godwin

    Help someone else with what someone helped you!

  4. #4

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Help with axwebbrowser control

    heres the code guys..
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         newsub(Me.AxWebBrowser1, Me.ListBox1)
    3.     End Sub
    4.     Private Sub newsub(ByVal browser As AxSHDocVw.AxWebBrowser, ByVal lstbox As ListBox)
    5.         For i As Integer = 0 To (lstbox.Items.Count - 1)
    6.             browser.Navigate(lstbox.Items.Item(i))
    7.         Next
    8.     End Sub
    9.  
    10.  
    11.  
    12. In another scenario,I tried this...
    13.  
    14.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    15.         newsub(Me.AxWebBrowser1, Me.ListBox1)
    16.     End Sub
    17.     Private Sub newsub(ByVal browser As AxSHDocVw.AxWebBrowser, ByVal lstbox As ListBox)
    18.         For i As Integer = 0 To (lstbox.Items.Count - 1)
    19. fixit:      If setme = True Then
    20.                 setme = False
    21.                 browser.Navigate(lstbox.Items.Item(i))
    22.             Else
    23.                 MsgBox("doesnt work")
    24.             End If
    25.  
    26.         Next
    27.     End Sub
    28.  
    29.     Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
    30.         setme = True
    31.     End Sub

    Both dont work as expected...some logical error...so,help me please
    Godwin

    Help someone else with what someone helped you!

  5. #5
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Help with axwebbrowser control

    Ok. This is what you are trying to do, correct me if I am wrong.
    You have a list of documents that you want to open in your browser.
    You want to load them in one at a time
    You want the next document to wait to load until the loading doc is done
    Is that correct?

    Something that you could try is this:
    VB Code:
    1. Private NextPage as Integer = 0
    2.  
    3. Private Sub Button1_Click(sender...) Handles Button1.Click
    4.    AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
    5. End Sub
    6.  
    7. Private Sub Private Sub AxWebBrowser1_DocumentComplete(sender...) Handles AxWebBrowser1.DocumentComplete
    8.    NextPage += 1
    9.    If NextPage < lstbox.Items.Count Then
    10.        AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
    11.    Else
    12.       NextPage = 0
    13.    End If
    14. End Sub
    This should work if my understanding of what you want to do is correct. Just note I typed this in ie so it is untested and there may be a few errors you need to fix.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  6. #6

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Help with axwebbrowser control

    Hi,
    You're code changes the browsercontrols page only when you click the button.
    What you said is exactly right,but I want to automate that process.Once the first page is done,it should automatically go to the next url in the listbox

    Thanks
    Godwin

    Help someone else with what someone helped you!

  7. #7
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Help with axwebbrowser control

    That's what the code should do. You click the button to start the cycle, then in the DocumentComplete event it moves onto the next page, which should cause it to keep going until all pages are loaded.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  8. #8

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Help with axwebbrowser control

    it works :-s but it didnt work when i tried something like this before...maybe I did some mistake..
    Thanks
    Godwin

    Help someone else with what someone helped you!

  9. #9

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Help with axwebbrowser control

    Hey,a slight modification..
    This is how it should be
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         NextPage = 0
    3.         AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
    4.     End Sub
    5.  
    6.     Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
    7.         '  MsgBox(lstbox.Items.Item(NextPage))
    8.         If NextPage < lstbox.Items.Count Then
    9.             AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
    10.             NextPage += 1
    11.         End If
    12.     End Sub
    Thanks a bunch bud
    Godwin

    Help someone else with what someone helped you!

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