zoukankan      html  css  js  c++  java
  • C#让WebBrowser滚动条自动上下滚动一定时间

    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));
    }
    }
    }

  • 相关阅读:
    演示使用string对象(续)
    P2216 [HAOI2007]理想的正方形 单调队列
    SP1805 HISTOGRA
    P4556 [Vani有约会]雨天的尾巴 树链剖分 线段树合并
    codeforces 600E 线段树合并
    HDU2197 本原串
    P3806 【模板】点分治1
    牛客10 Popping Balloons
    P3261 [JLOI2015]城池攻占 左偏树
    P4549 【模板】裴蜀定理
  • 原文地址:https://www.cnblogs.com/wolly88/p/4271550.html
Copyright © 2011-2022 走看看