Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim i As Long
Dim existed As Boolean
If KeyCode = 13 Then '回车键的ascii码
If Left(Combo1.Text, 7) <> "http://" Then
Combo1.Text = "http://" + Combo1.Text
End If
WebBrowser1.Navigate Combo1.Text '打开网页
For i = 0 To Combo1.ListCount - 1 '添加到记录栏
If Combo1.List(i) = Combo1.Text Then
existed = True
Exit For
Else
existed = False
End If
Next
If Not existed Then
Combo1.AddItem (Combo1.Text)
End If
End If
End Sub
Private Sub Command1_Click()
CommonDialog1.ShowOpen
WebBrowser1.Navigate CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Combo1.Text = ""
Combo1.Top = 0 '设置URL地址栏的位置
Combo1.Left = 0
WebBrowser1.Top = Combo1.Top + Combo1.Height '设置页面浏览区的位置
WebBrowser1.Left = 0
Form_Resize
StatusBar1.Style = 0 'statusbar由多个对象组成,style是确定显示的模式
ProgressBar1.ZOrder '控件放在其他图形的前端,以免被挡住
End Sub
Private Sub Form_Resize()
On Error GoTo a
Combo1.Width = Form1.Width - 100 '地址栏随窗口宽度而变化
WebBrowser1.Width = Combo1.Width '浏览区界面调整
WebBrowser1.Height = Form1.Height - Combo1.Height - 1000
ProgressBar1.Top = Me.Height - StatusBar1.Height - 330 '进度条界面调整
ProgressBar1.Left = 0.25 * StatusBar1.Width
ProgressBar1.Width = 0.75 * Me.Width - 250 'me和form:在form1里写的代码,如果需要copy到form2里,用me的话,代码不用改就能用,因为此时me就指代form2了;写成form1的话还要改成form2
a:
End Sub
Private Sub WebBrowser1_DownloadBegin()
StatusBar1.SimpleText = "载入中..."
End Sub
Private Sub WebBrowser1_DownloadComplete()
StatusBar1.SimpleText = "下载完成"
ProgressBar1.Value = 0
End Sub
Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
If ProgressMax = 0 Then Exit Sub '调整显示的进度条
ProgressBar1.Max = ProgressMax
If Progress <> -1 And Progress <= ProgressMax Then
ProgressBar1.Value = Progress
End If
End Sub
Private Sub WebBrowser1_TitleChange(ByVal Text As String)
Combo1.Text = WebBrowser1.LocationURL
End Sub