Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

Webpage thumbnailer

, 17 Aug 2006
An article on how to get a webpage thumbnail and give your favorite links a face.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace net.grool.util
{
	public partial class BrowserForm : Form
	{
		public BrowserForm()
		{
			InitializeComponent();

			webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);

		}
		PicDoc picDoc = null;

		public PicDoc CurDoc
		{
			get { return picDoc; }
			set { picDoc = value; }
		}
		/// <summary>
		/// This method calls starts download of the page .
		/// </summary>
		/// <param name="url"></param>
		public void getImageFromUrl(string url)
		{

			try
			{
				this.webBrowser1.Url = new Uri(url);

			}
			catch (Exception ex)
			{

				MessageBox.Show(ex.Message);

			}



		}
		/// <summary>
		/// This event handler is called after document is loaded in browser.
		/// We copy content of the invisible browser to new bitmap and pass it to PicDoc object which in turn will fire refreshPicture event.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void webBrowser1_DocumentCompleted(Object sender, WebBrowserDocumentCompletedEventArgs e)
		{

			try
			{

				Bitmap docImage = new Bitmap(600, 800);
				webBrowser1.DrawToBitmap(docImage, new Rectangle(webBrowser1.Location.X, webBrowser1.Location.Y, webBrowser1.Width, webBrowser1.Height));
				this.picDoc.Image = this.picDoc.getSizedImage(docImage);

			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}


		}

		

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

dooskoobi
Web Developer
Belgium Belgium
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 17 Aug 2006
Article Copyright 2006 by dooskoobi
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid