namespace test_gundong
{
public partial class Form1 : Form
{
int current = 0;
Timer timeDown = new Timer();
Timer timeUp = new Timer();
public Form1()
{
InitializeComponent();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
webBrowser1.Navigate("http://www.yahoo.com.cn");
timeDown.Interval = 100;
timeDown.Tick += new EventHandler(timeDown_Tick);
timeUp.Interval = 100;
timeUp.Tick += new EventHandler(timeUp_Tick);
}
private void Form1_Load(object sender, EventArgs e)
{
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
current = 0;
timeDown.Enabled = true;
}
void timeDown_Tick(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
int height = webBrowser1.Document.Body.ScrollRectangle.Height;
current += height / 100;
if (current >= height)
{
current = height;
timeDown.Enabled = false;
timeUp.Enabled = true;
}
doc.Window.ScrollTo(new Point(0, current));
}
void timeUp_Tick(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
int height = webBrowser1.Document.Body.ScrollRectangle.Height;
current -= height / 100;
if (current <= 0)
{
current = 0;
timeUp.Enabled = false;
}
doc.Window.ScrollTo(new Point(0, current));
}
}
}