From: Eduardo on 20 Sep 2009 18:40 Mike Williams escribi�: > The following seems to work okay, although I haven't tested it fully and > I always have timing trouble when using any of the WebBrowser Control > events so the code to create the bitmap is in the click event of a > button, which should be clicked after the web page has visibly loaded. > It obviously needs a bit more work to solve the timing problem, but I > can't seem to hit the correct delay or find the right event that suits > all web pages. Paste the following into a Form containing a WebBrowser > Control and a Picture Box and a Command Button: > > Mike Excellent
From: Sneha Menon on 21 Sep 2009 08:07 Thank You all From a quick look Mike's solution seems to be on the right track. But it works only when Command1 is manually clicked. I tried putting the code inside command button's Click, in a subroutine and tried calling it from WebBrowser's downloadcomplete event a) Result: Picture1 remained blank; blank was saved as bmp b)I tried the same with a timer with long delay(10 seconds, to be sure). Same result. c) NOT from downloadcomplete event. Waited more than enough time to let the webpage load. Then with another buttonClick enabled the timer and let it run the subroutine after 10 seconds. Same result My current query is just this: Frankly I could not quite understand what makes the CODE under command1 work when explicitly clicked but fail when put in a subroutine with or without delay(timer). Mike or Anybody here who understand this peculiar behaviour please enlighten me so that I can carry on from there Regards Sneha
From: Mike Williams on 21 Sep 2009 08:30 "Sneha Menon" <spiderangelo(a)gmail.com> wrote in message news:1a154622-e99f-41c0-a748-b9ef8339b11b(a)m33g2000pri.googlegroups.com... > Thank You all. From a quick look Mike's solution seems > to be on the right track. But it works only when Command1 > is manually clicked. Yes. That's what I said when I posted the code. It does seem odd, and I haven't yet had time to look into (going out soon so and I'm in a rush so it will probably be some time before I get around to it). In the meantime I've noticed something that might lead to a solution. It does work when you place the "copy and save as bitmap" code in a Command Button click event (as you have noted) but it does NOT work when you instead place the same code in the Form's Click event! It appears to be something to do with an input box on the web page itself having the focus (with the flashing text insertion cursor) and the "copy as bitmap" code fails to work whilst that web page box still has the focus (as it still does if you click the Form to run some Form Click event code, because the Form does not take the focus from the browser control). But, if you click something that does take the focus (a text box or a command button or whatever) and THEN click the Form the "copy as bitmap" code in the Form's Click event DOES work. So, it seems as though we need to transfer focus from the Browser Control to something else before running the "copy as bitmap" code. There may be other thjngs that need doing as well, but the focus thing is the first place I would be heading first when looking for a solution. Mike
From: Sneha Menon on 21 Sep 2009 09:03 It works, Thank you Mike I just moved the command1 out of sight, and put command1.setfocus before calling the copy and bitmap subroutine. (In actual project I could shift the focus to someother useful component) Thank you a lot Regards Sneha
From: Eduardo on 21 Sep 2009 13:31
Sneha Menon escribi�: > Thank You all > > From a quick look Mike's solution seems to be on the right track. > > But it works only when Command1 is manually clicked. I tried putting > the code inside command button's Click, in a subroutine and tried > calling it from WebBrowser's downloadcomplete event > a) Result: Picture1 remained blank; blank was saved as bmp > > b)I tried the same with a timer with long delay(10 seconds, to be > sure). Same result. > > c) NOT from downloadcomplete event. Waited more than enough time to > let the webpage load. Then with another buttonClick enabled the timer > and let it run the subroutine after 10 seconds. Same result > > My current query is just this: > Frankly I could not quite understand what makes the CODE under > command1 work when explicitly clicked but fail when put in a > subroutine with or without delay(timer). Mike or Anybody here who > understand this peculiar behaviour please enlighten me so that I can > carry on from there Instead of DowloadComplete Use DocumentComplete: Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As _ Object, URL As Variant) If Len(URL) > 8 Then Command1_Click End If End Sub |