Complex Processing In the Webbrowser control

 

I'm working on system that has a complex browser based in the WebBrowser control and I've found somepages that it cannot process in ways that I do not understand.

www.vanishingpointgame.com is a page that it cannot process and that why I am using that page to test on. I have taken the most simple test case in a form. It has a designer created groupbox with a dynamically created webbrower. It navigates to  www.vanishingpointgame.com.

I do the following operations:

I choose the box on the far left. I click on the little tab at the back of the box.

Nothing happens.     In contrast IE7 opens a new dedicated widow.

The interesting thing about the webbrower control is that if I minimize the form and maximize and click on that little tab at the back of the box, the test program will create a new window just like IE7.

This is what confuses me. I ask myself what kind of messages the webbrowser control is getting that a minimize/maximize will cause a state change in such a way that it then works.

 

Here is the simplest test case. As you can see it has no code in any of the events which are useful in the debugger to observe the events of the web browser

Public Class Form1

    Protected Friend WithEvents wb As New WebBrowser

    Private Sub Form1_Load(ByVal sender As Object, _

                           ByVal e As System.EventArgs) Handles Me.Load

        wb.Location = New Point(0, 0) : wb.Size = GroupBox1.Size

        GroupBox1.Controls.Add(wb)

        wb.Navigate("http://www.vanishingpointgame.com/")

    End Sub

 

  

 

    Private Sub wb_DocumentCompleted(ByVal sender As Object, _

      ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) _

                   Handles wb.DocumentCompleted

        wb.AllowWebBrowserDrop = True

    End Sub

 

 

 

    Private Sub wb_Navigated(ByVal sender As Object, _

        ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) _

        Handles wb.Navigated

 

    End Sub

 

    Private Sub wb_Navigating(ByVal sender As Object, _

                        ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) _

                        Handles wb.Navigating

 

    End Sub

 

    Private Sub wb_NewWindow(ByVal sender As Object, _

                       ByVal e As System.ComponentModel.CancelEventArgs) _

                       Handles wb.NewWindow

 

    End Sub

 

    Private Sub wb_Validated(ByVal sender As Object, _

                             ByVal e As System.EventArgs) Handles wb.Validated

 

    End Sub

 

    Private Sub wb_Validating(ByVal sender As Object, _

                    ByVal e As System.ComponentModel.CancelEventArgs) Handles wb.Validating

 

I'm going to put a wndproc in to see what the messages are. I really do not understand this behavior.

 




Answer this question

Complex Processing In the Webbrowser control

  • IceAngel89

    oops - bookmark=breakpoint. If you set one on the 'End Sub' of the lostfocus event, you'll see that the pop-up does appear - it doesn't if there's no breakpoint set, so I was thinking some code that interrupts the event temporarily or doing something to the wb in that event, might trigger the popup by code alone.



  • efratian

    I've been working on this more. You're right about the scrollbars, but when I set the control to fill the form and the maximize the form the small tab on the box does nothing and there are not scrollbars to trigger anything.

    I hate sendkeys but is there a key stroke that causes scrolling Is there an event where I can recognize this condition. So far I haven't found anything.

    Sendkey will scroll. But that's not the problem. I haven't been able to identify this condition programatically.

    I receive a Document Complete event after navigating to the intial page and that's the last event I see.



  • Abe1816

    I've made the page scroll by using a timer and navigating to this javascript:

    wb.Navigate({window.scrollBy(0,1)};")
    (Note that capitalization is important in Javascript)

    But the box doesn't react until I specifically use the mouse to scroll, so perhaps it's just some mouse-triggered updatefunction in the webbrowser, or in one of the .js files attached to the page.

    I think .Net is included in the browserdetection stuff (userAgent), so it should be detecting alright, but that's just my amateur-opinion :)



  • Mable

    Found something! Each time you click, the wb loses focus - if you bookmark the End Sub, the window pops up, so maybe put some code in it:

    Private Sub wb_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles wb.LostFocus

    End Sub


  • ParkerMelvin

    I created your webbrowser in a groupbox that's too small to show the whole page. Clicking on the box does not bring the popup until I scroll the webbrowser just a little bit, so it's triggered by the repositioning of the document inside the browser.



  • Jeremy - MS Research

     

    Ahhhhh thank you. I'll try that and see what it does in the real code.

    Interesting enough this has been a reported bug in the bug database since October and is still unresolved. I filed a second bug report on it.

    ....ummmm " bookmark the End Sub"



  • jwagner20

    That's a really BIG Help. Thank you!!!!!!!!!



  • Álvaro Peñarrubia

     

     

    That's really good thinking. I did spend the evening looking at control messages to the wb. To be honest, I have a hard time making sense of them even when they are labeled. There are stil the lparams and the wparams too, so the messages with the same names aren't really doing the same thing. I did try to interrupt the sequences. I know there are many sequences that look like setfocus-killfocus so the messages are constantly waking up the control and putting it to sleep. I was very Curious about the SetContext message. I wonder what that does

    I'll keep looking at it. With enough bug reports, MS may look into it. There are at least two now.

    Thank you very much.



  • Balavenkatesh

    I found a bug report on this and I'm filing a second one.

    Thanks for all of the help. I have spent all night looking at wndproc messages and they aren't telling me alot.



  • Complex Processing In the Webbrowser control