I’m trying to make a custom scroll bar for Web browser Control.
I used a Scroll Bar Control for this,so i attached Scroll Bar Control to Web browser Control
use following code:
Doc = (mshtml.HTMLDocument)browser.Document;
Doc.parentWindow.document.body.style.overflow = "hidden";
mshtml.IHTMLElement2 ScrolablePlace= (mshtml.IHTMLElement2)Doc.getElementById("ScrolablePlace");
ScrollBar.ViewportSize = browser.ActualHeight;
ScrollBar.Maximum = ScrolablePlace.scrollHeight;
and while scroling scrolbar:
private void ScrollBar_Scroll(object sender, ScrollEventArgs e)
{
if (Doc != null)
{
Doc.parentWindow.scroll(0, (int)e.NewValue);
}
}
this is work,but ScrollBar.Maximum value is always larger than scroll bar place.dose ScrollBar.ViewportSize and ScrollBar.Maximum
set correctly?
I Hope i could explain my problem correctly with this image:

After some research, I’ve found that a scroll bar
maximumproperty must calculate from this formula :so i simply do this and it work fine: