Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Webbrowser troubles

I'm using a Webbrowser control (IE 5) in my application, from time to time I tell the browser it has to refresh the page (can be updated by another application) and go to the end of the page.
Refreshing works well, but positioning at the end doesn't work.  I'm using SendKeys "^{END}", but this works only when I first click once on the webbrowser control.  Then it positions itself at the end, otherwise it doesn't do anything.

Could someone please help me or does anyone know a good 3rd party webbrowser control (support of HTML 4) with more functionality, like hiding scrollbars, ...  

Thanks
Gunther
0
guntherds
Asked:
guntherds
1 Solution
 
VbmasterCommented:
Have you tried with the mouse_event API, clicking on the browser area before attempting the ^{END} sendkey thingie?

Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4


(use mouse_event with leftdown, add a doevents and then another mouse_event now with leftup - this will emulate a click with the mouse)
0
 
martingpCommented:
Hi guntherds

I would approch the problem from a different angle than using send keys. Take advantage of the HTML language by using the 'bookmark' tag.

Place this code at the end of your document:
<A NAME="end"></A>

When you refresh don't use the refresh method just the navigate method like this:
webbrowser.navigate "yourpage.html#end"

This will tell the webbrowser control to show yourpage.html and scroll down to the 'end' tag.

PS.
The IE browser control provide everything you need for browser development :-)
0
 
guntherdsAuthor Commented:
Sorry, I don't have time right now to test it, but if it works you certainly will get the points
But how can I solve this: I'm appending lines to this HTML-file and tell my 'browser'-component to refresh.
I could do it the way you tell me, but then after each line line I would have to put this tag, which tag will the browser then take for positioning at the end?
Or do you have another solution?
0
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.

 
martingpCommented:
Hi gunther

First of all the method I desribed above does work.

Here is the answer to your second problem:

You say that you append lines to the end of the file, possibly from different applications. All you have to do is add the 'bookmark' code to the last line in the file. Everytime you update it's just a matter of deleting the last line (bookmark) append the new data and then add the bookmark line again...

If you have enough control over your data you could also re-create the html file everytime you do an update (if you have a limited amount of data).

If there are any conflicts please provide more details.

Good luck...
0
 
guntherdsAuthor Commented:
I don't doubt it will work :-)
I'll test it asap
Keep you informed
0
 
AzraSoundCommented:
Dim w As Object
Set w = WebBrowser1.Document.parentwindow
w.Scroll 0, 30000
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now