简单的Web浏览器
请问各位有经验的人,如何做一个简单的web浏览器?不甚感激
程序代码:
using System; using System.Windows.Forms; namespace WebBrowser { public partial class FormMain : Form { #region 构造函数 public FormMain() { InitializeComponent(); ButBackward.Click += ButBackward_Click; ButForward.Click += ButForward_Click; TbAddress.KeyDown += TbAddress_KeyDown; Wb.CanGoBackChanged += Wb_CanGoBackChanged; Wb.CanGoForwardChanged += Wb_CanGoForwardChanged; Wb.DocumentTitleChanged += Wb_DocumentTitleChanged; Wb.Navigated += Wb_Navigated; } #endregion #region 控件事件 void ButBackward_Click(object sender, EventArgs e) { Wb.GoBack(); } void ButForward_Click(object sender, EventArgs e) { Wb.GoForward(); } void TbAddress_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && !string.IsNullOrWhiteSpace(TbAddress.Text)) Wb.Navigate(TbAddress.Text); } void Wb_CanGoBackChanged(object sender, EventArgs e) { ButBackward.Enabled = Wb.CanGoBack; } void Wb_CanGoForwardChanged(object sender, EventArgs e) { ButForward.Enabled = Wb.CanGoForward; } void Wb_DocumentTitleChanged(object sender, EventArgs e) { Text = string.Concat("Web Broswer by - ", Wb.DocumentTitle); } void Wb_Navigated(object sender, WebBrowserNavigatedEventArgs e) { TbAddress.Text = Wb.Url.ToString(); } #endregion } }
不知道这个够不够简单,也许前进后退按钮都不用是最简单的吧。
[ 本帖最后由 mmxo 于 2012-11-7 23:21 编辑 ]