当前位置: 移动技术网 > IT编程>开发语言>c# > C#实现的滚动网页截图功能示例

C#实现的滚动网页截图功能示例

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#实现的滚动网页截图功能。分享给大家供大家参考,具体如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.linq;
using system.text;
using system.windows.forms;
namespace windowsformsapplication1
{
  public partial class form1 : form
  {
    private int _currentwidth = 1024;
    private bitmap _currentbitmap = null;
    public form1()
    {
      initializecomponent();
    }
private void button1_click(object sender, eventargs e)
{
  if (webbrowser1.document == null)
    return;
  try
  {
    int width = _currentwidth;
    int height = webbrowser1.document.body.scrollrectangle.height;
    webbrowser1.width = width;
    webbrowser1.height = height;
    _currentbitmap = new bitmap(width, height);
    webbrowser1.stop();
    webbrowser1.drawtobitmap(_currentbitmap, new rectangle(0, 0, width, height));
    picturebox1.image = _currentbitmap;
  }
  catch (exception ex)
  {
    messagebox.show(ex.tostring(), "遇到错误", messageboxbuttons.ok, messageboxicon.error);
  }
}
  }
}

更多关于c#相关内容感兴趣的读者可查看本站专题:《c#图片操作技巧汇总》、《c#常见控件用法教程》、《winform控件用法总结》、《c#数据结构与算法教程》、《c#面向对象程序设计入门教程》及《c#程序设计之线程使用技巧总结

希望本文所述对大家c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网