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 浏览器 { public partial class Form1 : Form { public Form1() { InitializeComponent(); webBrowser1.Navigate(txtAddress.Text); } private void toolStripButton5_Click(object sender, EventArgs e) { webBrowser1.Navigate(txtAddress.Text); } private void toolStripButton1_Click(object sender, EventArgs e) { webBrowser1.GoBack(); } private void toolStripButton2_Click(object sender, EventArgs e) { webBrowser1.GoForward(); } private void toolStripButton4_Click(object sender, EventArgs e) { webBrowser1.Refresh(); } private void toolStripButton3_Click(object sender, EventArgs e) { webBrowser1.Stop(); } private void address_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { webBrowser1.Navigate(txtAddress.Text); } } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("将关闭窗口!"); Application.Exit(); } private void baidu_Click(object sender, EventArgs e) { //search.Text; } private void address_Click(object sender, EventArgs e) { txtAddress.Focus(); txtAddress.SelectAll(); } private void search_Click(object sender, EventArgs e) { search.Clear(); search.Focus(); } private void btnNewPage_Click(object sender, EventArgs e) { TabPage tp = new TabPage(); WebBrowser wb = new WebBrowser(); tp.Controls.Add(wb); wb.Dock = DockStyle.Fill; tap.Controls.Add(tp); tap.SelectedTab = tp; tp.Text = "新页面"; } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { pbWb.Visible = false; } private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) { if (e.MaximumProgress == 0) { return; } pbWb.Visible = true; //这个才是真的进度条,不是你说+10就可以的 //这个就是进度条 我要改名 命名说了要规范 你的名字都没改 你干嘛?你那个是假进度你不知道?101010101010这是什么 //pbWb.Maximum = 100; //var value =Convert.ToInt32( e.CurrentProgress / e.MaximumProgress*100); //算百分比 // pbWb.Value = value; if ((e.CurrentProgress > 0) && (e.MaximumProgress > 0)) { pbWb.Maximum = Convert.ToInt32(e.MaximumProgress);//设置正在加载的文档总字节数 pbWb.Step = Convert.ToInt32(e.CurrentProgress);////获取已下载文档的字节数 pbWb.PerformStep(); } else if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)//加载完成后隐藏进度条 { pbWb.Value = 0; pbWb.Visible = false; } } //这样我们就可以构造一个创建窗口的方法 private void CreateNewTab(string name) { TabPage tp = new TabPage(name);//创建一个tabpage tap.TabPages.Add(tp);//新增一个tabpage 加刚才创建的 WebBrowser wb = new WebBrowser();//这个意思就是 把webbrower 用wb 代替不?新建一个wb控件 wb.Dock = DockStyle.Fill;//设置填充整个父容器 tp.Controls.Add(wb);//把webbrowser放入tabpage里 tap.SelectedTab = tp;//激活当前 } private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { //kasi le if (e.Url.Equals(new Uri(txtAddress.Text))) { return; } MessageBox.Show("可以创建心的窗体 你想要的样子 自己开发吧 ,太卡了 。。。。。"); } } } /* private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { pbWb.Visible = false; } private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) { if (e.MaximumProgress == 0) { return; } pbWb.Visible = true; //这个才是真的进度条,不是你说+10就可以的 //这个就是进度条 我要改名 命名说了要规范 你的名字都没改 你干嘛?你那个是假进度你不知道?101010101010这是什么 //pbWb.Maximum = 100; //var value =Convert.ToInt32( e.CurrentProgress / e.MaximumProgress*100); //算百分比 // pbWb.Value = value; if ((e.CurrentProgress > 0) && (e.MaximumProgress > 0)) { pbWb.Maximum = Convert.ToInt32(e.MaximumProgress);//设置正在加载的文档总字节数 pbWb.Step = Convert.ToInt32(e.CurrentProgress);////获取已下载文档的字节数 pbWb.PerformStep(); } else if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)//加载完成后隐藏进度条 { pbWb.Value = 0; pbWb.Visible = false; } } //这样我们就可以构造一个创建窗口的方法 private void CreateNewTab(string name) { TabPage tp = new TabPage(name);//创建一个tabpage tap.TabPages.Add(tp);//新增一个tabpage 加刚才创建的 WebBrowser wb = new WebBrowser();//这个意思就是 把webbrower 用wb 代替不?新建一个wb控件 wb.Dock = DockStyle.Fill;//设置填充整个父容器 tp.Controls.Add(wb);//把webbrowser放入tabpage里 tap.SelectedTab = tp;//激活当前 } private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { if (e.Url.Equals(new Uri(txtAddress.Text))) { TabPage tp = new TabPage(); WebBrowser wb = new WebBrowser(); tp.Controls.Add(wb); wb.Dock = DockStyle.Fill; tap.Controls.Add(tp); tap.SelectedTab = tp; tp.Text = "新页面"; } MessageBox.Show("123"); return; } } } */