FAQ: how to access the webbrowser scroll bar

Source: Internet
Author: User

Question ===================================================== =

I use the webbrowser control but want to use my own scroll bar, but I don't know how to get the length of the scroll bar in webbrowser. What should I do? Thank you !!

2004-10-24

A: ===================================================== =

Sorry, it took a long time to reply to your question.
Webbrowser's scroll bar is not a common Windows scroll bar. It cannot be accessed using APIs such as getscrollpos or getscrollinfo. The followingCodeDemonstrate how to access the browser's scroll bar through the HTML interface in VC.

Hresult hr;
Idispatch * Pdisp = gethtmldocument ();
Assert (Pdisp); // If null, we failed

// Obtain the HTML document pointer
Ihtmldocument2 * pdocument = NULL;
HR = Pdisp-> QueryInterface (iid_ihtmldocument2, (void **) & pdocument );
Assert (succeeded (HR ));
Assert (pdocument );

Ihtmlelement * pbody = NULL;
HR = pdocument-> get_body (& pbody );
Assert (succeeded (HR ));
Assert (pbody );

// Obtain the ihtmlelement2 interface pointer from the body to access the scroll bar
Ihtmlelement2 * pelement = NULL;
HR = pbody-> QueryInterface (iid_ihtmlelement2, (void **) & pelement );
Assert (succeeded (HR ));
Assert (pelement );

// Scroll down 100 pixels
Pelement-> put_scrolltop (100 );

// Obtain the true height of the document, not the height of the visible area
Long scroll_height;
Pelement-> get_scrollheight (& scroll_height );

// Obtain the true width of the document, not the width of the visible area
Long scroll_width;
Pelement-> get_scrollwidth (& scroll_width );

// Obtain the position of the scroll bar, starting from the top
Long scroll_top;
Pelement-> get_scrolltop (& scroll_top );

Reference address: FAQ: how to access the webbrowser scroll bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.