In this Article:
Nowadays There are so many Advanced browser for surfing the Internet, but it is quit interesting to use your own browser. This article explains that how to create your own browser. just follow simple step by step instructions below...
Note:
1.you need to be Visual studio 2008 or Visual studio 2010 Installed.
2.It is only simple browser not multi-tabbed..
Experience your own browser......... Enjoy it....
Basic Design of Simple Browser :
Step 1- Design
- .Open new project & create new form in VS2010 or VS2008
- Add the Controls
- Buttons(For Navigations ex: Refresh, Forward, Back......)
- TextBox(For Enter URL)
- Web Browser(For Show the Web Pages)
- Progress Bar (For Navigation Range)
Fig :Basic Design |
Fig : Set Properties of Web Browser Control |
Fig : Generate these four Event in Web Browser Control |
Step 2-Coding
using System;
using System.Collections;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace webnote
{
public partial class Form1 : Form
{
int i=0,j=0;
string s = null;
public Form1()
{
InitializeComponent();
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
//Initialize the Minimum and Maximum value of Progress Bar
}
//Behind the Home button
private void buttonHome_Click(object sender, EventArgs e)
{
webBrowser1.GoHome(); //Navigate to web Address set in the Web Browser control Fig:2 Properties
}
//Behind the Go button
private void buttonGo_Click(object sender, EventArgs e)
{
// Avoiding Conflict "http"
if(TextBoxUrl.Text.StartsWith("http://")||TextBoxUrl.Text.StartsWith("https://"))
{
TextBoxUrl.Text = TextBoxUrl.Text.Remove(0, 8);
}
Uri add;
try
{
add = new Uri("http://"+TextBoxUrl.Text);
webBrowser1.Url = add;
}
catch (Exception)
{
MessageBox.Show("Enter Valid Web Address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
progressBar1.Value = 0;
}
//Behind Refresh Button
private void buttonRefresh_Click(object sender, EventArgs e)
{
webBrowser1.Refresh();
}
//Behind Back Button
private void buttonBack_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}
//Behind Forward Button
private void buttonBack_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}
//Behind Stop Button
private void buttonBack_Click(object sender, EventArgs e)
{
webBrowser1.Stop();
}
//Create Event in Web browser Control
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
progressBar1.Increment(2);
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
TextBoxUrl.Text.Text = webBrowser1.Url.ToString();
progressBar1.Show();
progressBar1.Value = 20;
}
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
progressBar1.Value = 80;
}
private void webBrowser1_DocumentCompleted_1(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
progressBar1.Value = 100;
progressBar1.Hide();
}
}
}
Post your Valuable Comments........
No comments:
Post a Comment