How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Hi all i wonder how i can specify and predefine the location of scrollbar when using Form1.WebBrowser1.Navigate in vb6 form. I want for example when the form loads the scroll bar is at the location shown in pic . Thanks
Code:
Private Sub Form_Load()
Form1.WebBrowser1.Navigate "http://www.cnn.com"
Form1.Show
End Sub
http://i5.photobucket.com/albums/y18...asposition.jpg
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
are you using a separate scroll bar?
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Quote:
Originally Posted by ganeshmoorthy
are you using a separate scroll bar?
well it is the default scroll bar as u see in the pic and code!
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
where is the picture and i do not have option to open the attachments...when the content doesnt fit the page automatically you will get the scroll bar by default..
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Quote:
Originally Posted by ganeshmoorthy
where is the picture and i do not have option to open the attachments...when the content doesnt fit the page automatically you will get the scroll bar by default..
here i the pic
http://i5.photobucket.com/albums/y18...asposition.jpg
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Add a reference to Microsoft HTML Object Library and try this,
VB Code:
Option Explicit
Dim HTMLElement As IHTMLElement2
'-------------------------
Private Sub Form_Load()
WebBrowser1.Navigate2 "http://www.google.com"
End Sub
'-------------------------
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If WebBrowser1 = pDisp Then 'document loaded successfully
Set HTMLElement = WebBrowser1.Document.body
HTMLElement.scrollTop = 100 'Scroll to our point
End If
End Sub
Edit: This is not working on VBF. Due to some script ?
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Thanks for u reply but it did not work!! how i spacify the location of the scroller ? i draged Microsoft HTML Object Library in to form and i see strange white thing . What is that for ?
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Don't use the control. (I've never used it. Don't know what it does).
Goto Project>References menu.
From the dialogbox that opens, select "Microsoft HTML Object Library".
Click OK.
If you have done it, you shold see intellisence help when you press (.) after typing the "IHTMLElement" variable name.
From the .scrollTop, .scrollHeight, .scrollLeft, .scrollWidth properties of IHTMLElement2 interface, you can get/set scrollbar positions.
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Quote:
Originally Posted by iPrank
Don't use the control. (I've never used it. Don't know what it does).
Goto Project>References menu.
From the dialogbox that opens, select "Microsoft HTML Object Library".
Click OK.
If you have done it, you shold see intellisence help when you press (.) after typing the "IHTMLElement" variable name.
From the .scrollTop, .scrollHeight, .scrollLeft, .scrollWidth properties of IHTMLElement2 interface, you can get/set scrollbar positions.
thank u for u reply.could u tell me which one of them deals with scroll position ? I can not figure this out at all!
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
You'll need the scrollHeight to get maximum scroling position and scrollTop to set current scroll position.
Quote:
Originally Posted by MSDN
scrollHeight - Retrieves the scrolling height of the object.
scrollLeft - Sets or retrieves the distance between the left edge of the object and the leftmost portion of the content currently visible in the window.
scrollTop - Sets or retrieves the distance between the top of the object and the topmost portion of the content currently visible in the window.
scrollWidth - Retrieves the scrolling width of the object.
From here: http://msdn.microsoft.com/library/de...2/element2.asp
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Thank u for u reply iprank. I keep changing the value of
HTMLElement.scrollTop = 10
but the scroll position never changes! could u tell me what is wrong here.Thanks
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Sorry. i have no idea. :(
As I have already mentioned in post#6, it is working perfectly for google, but it is not working for VBF.
The cnn site is giving me script error. So I couldn't test on it.
Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?
Quote:
Originally Posted by iPrank
Sorry. i have no idea. :(
As I have already mentioned in post#6, it is working perfectly for google, but it is not working for VBF.
The cnn site is giving me script error. So I couldn't test on it.
Thank u for u reply. Actually i tested it for google.com and tried to change the value of HTMLElement.scrollTop = 20 to diffrent things but i did not notice any changes .Am i missing some thing here?Thanks