Results 1 to 13 of 13

Thread: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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




  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?

    are you using a separate scroll bar?
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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!

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    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..
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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

  6. #6
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: How to predefine location of scrollbar in Form1.WebBrowser1.Navigate?

    Add a reference to Microsoft HTML Object Library and try this,
    VB Code:
    1. Option Explicit
    2. Dim HTMLElement As IHTMLElement2
    3. '-------------------------
    4. Private Sub Form_Load()
    5.     WebBrowser1.Navigate2 "http://www.google.com"
    6. End Sub
    7. '-------------------------
    8. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    9.  
    10.     If WebBrowser1 = pDisp Then 'document loaded successfully
    11.         Set HTMLElement = WebBrowser1.Document.body
    12.         HTMLElement.scrollTop = 100 'Scroll to our point
    13.     End If
    14.  
    15. End Sub
    Edit: This is not working on VBF. Due to some script ?
    Last edited by iPrank; Apr 22nd, 2006 at 05:40 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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 ?

  8. #8
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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.
    Last edited by iPrank; Apr 22nd, 2006 at 11:26 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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!

  10. #10
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow 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

  12. #12
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width