From: Mike Williams on 21 Sep 2009 13:33 "Sneha Menon" <spiderangelo(a)gmail.com> wrote in message news:bcdd28bf-f35d-415e-a154-f45f3752de08(a)i18g2000pro.googlegroups.com... > It works, Thank you Mike You're welcome. > 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) Yep. In fact you could probably shift the focus to the PictureBox Control, which your code is using anyway to hold the bitmap. On tests the shifting of the focus works fine here and it solves the problem, and apparently it works okay at your end to. One other thing I noted is that the focus usually shifts back to the WebBrowser Control anyway as the various page elements download to complete the page and as the page "settles down" after the DocumentComplete event, but that doesn't seem to be a problem and it works fine as long as the focus is at least temporarily shifted to the CommandButton (or PictureBox or whatever) immediately before the code to save the bitmap is run, which is what you are currently doing. > Thank you a lot Again, you're very welcome. I don't normally do web page stuff myself and I never actually use the WebBrowser Control for any real work (just mess about occasionally as I do with everything else) and I can't at the moment see why it was necessary to at least temporarily shift the focus away from the WebBrowser whilst the "save as bitmap" code is run, but I suppose all sorts of things are going on under the hood there as the various things are happening, presumably in other threads initiated by the WebBrowser Control, so it must be somehting to do with that. Mike
From: Eduardo on 21 Sep 2009 14:13 Mike Williams escribi�: > > "Sneha Menon" <spiderangelo(a)gmail.com> wrote in message > news:bcdd28bf-f35d-415e-a154-f45f3752de08(a)i18g2000pro.googlegroups.com... > >> It works, Thank you Mike > > You're welcome. > >> 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) > > Yep. In fact you could probably shift the focus to the PictureBox > Control, which your code is using anyway to hold the bitmap. On tests > the shifting of the focus works fine here and it solves the problem, and > apparently it works okay at your end to. One other thing I noted is that > the focus usually shifts back to the WebBrowser Control anyway as the > various page elements download to complete the page and as the page > "settles down" after the DocumentComplete event, but that doesn't seem > to be a problem and it works fine as long as the focus is at least > temporarily shifted to the CommandButton (or PictureBox or whatever) > immediately before the code to save the bitmap is run, which is what you > are currently doing. > >> Thank you a lot > > Again, you're very welcome. I don't normally do web page stuff myself > and I never actually use the WebBrowser Control for any real work (just > mess about occasionally as I do with everything else) and I can't at the > moment see why it was necessary to at least temporarily shift the focus > away from the WebBrowser whilst the "save as bitmap" code is run, but I > suppose all sorts of things are going on under the hood there as the > various things are happening, presumably in other threads initiated by > the WebBrowser Control, so it must be somehting to do with that. Hi, I have set the Picture as Visible = False and the command button also as Visible = False (or even removed it), so the only visible control left in the form was the Webbrowser, and the routine for saving still worked fine if I call it from the DocumentComplete, but it does not work if I call it from the Form's Click... I don't understand what is going on with it. I guess it must be something about the focus, about where the focus is in inside the webbrowser...
From: Mike Williams on 21 Sep 2009 14:23 "Eduardo" <mm(a)mm.com> wrote in message news:h98d9r$1uj$1(a)aioe.org... >>Sneha Menon escribi�: >> Thank you all . . . 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 . . . > Instead of DowloadComplete Use DocumentComplete: Actually I've only just noticed that Sneha mentioned the DownLoadComplete event, since I was concentrating mainly on the report that it only worked in a Command Button click (which is what I discovered myself even though I was using the DocumentComplete event). In my own original code I was already using the DocumentComplete event and it still often failed to work, failing more often than it succeeded, often cxhanging its behaviour depending on what web page I was loading. It did always reliably work from a Button Click event though, when clicking the button after the web page had fully loaded . .. . but . . . the interesting thing was that it did NOT work when exactly the same code was in the Form Click event (instead of in the CommandButton Click event), when clicking the Form after the web page had loaded, no matter how long I waited. That's what led me to come to the "focus problem" solution, because clicking the Form to run the "create the bitmap" code in the Form's click event (which did NOT work reliably) did not remove the focus from the WebBrowser (as is the case when clicking Forms) whereas clicking the CommandButton (which DID always work) does remove the focus from the WebBrowser. Anyway, deliberately setting focus to an otherwise unused control in code immediately before running the "create the webpage bitmap" code seems to work reliably when placed in the WebBrowser DownloadComplete event, whereas on my own machine it worked only intermittently before I did that. Mike
From: Eduardo on 21 Sep 2009 14:48 Mike Williams escribi�: >> Instead of DowloadComplete Use DocumentComplete: > > Actually I've only just noticed that Sneha mentioned the > DownLoadComplete event, since I was concentrating mainly on the report > that it only worked in a Command Button click (which is what I > discovered myself even though I was using the DocumentComplete event). > In my own original code I was already using the DocumentComplete event > and it still often failed to work, failing more often than it succeeded, > often cxhanging its behaviour depending on what web page I was loading. > It did always reliably work from a Button Click event though, when > clicking the button after the web page had fully loaded . . . but . . . > the interesting thing was that it did NOT work when exactly the same > code was in the Form Click event (instead of in the CommandButton Click > event), when clicking the Form after the web page had loaded, no matter > how long I waited. That's what led me to come to the "focus problem" > solution, because clicking the Form to run the "create the bitmap" code > in the Form's click event (which did NOT work reliably) did not remove > the focus from the WebBrowser (as is the case when clicking Forms) > whereas clicking the CommandButton (which DID always work) does remove > the focus from the WebBrowser. Anyway, deliberately setting focus to an > otherwise unused control in code immediately before running the "create > the webpage bitmap" code seems to work reliably when placed in the > WebBrowser DownloadComplete event, whereas on my own machine it worked > only intermittently before I did that. Look, the DownloadComplete event occurs a couple of times before the page is actually loaded for the URL specified in the navigate method. Thas's why I added the line 'If Len(URL) > 8 Then' The first time that the event occurs is when the webbrowser loads, the parameter URL comes with "", about the second time I didn't when it is fired, but the variable URL comes with "http:///".
From: Eduardo on 21 Sep 2009 14:50
Eduardo escribi�: > Look, the DownloadComplete event occurs a couple of times before the > page is actually loaded for the URL specified in the navigate method. > > Thas's why I added the line 'If Len(URL) > 8 Then' > > The first time that the event occurs is when the webbrowser loads, the > parameter URL comes with "", about the second time I didn't when it is > fired, but the variable URL comes with "http:///". PS: I mean, if you check the bmp file saved before the third DownloadComplete event, you'll see an empty image. |