form1.frm
来自「VB源码,是初学者的福因.让你很快掌握VB编程」· FRM 代码 · 共 268 行
FRM
268 行
VERSION 5.00
Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "shdocvw.dll"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3660
ClientLeft = 60
ClientTop = 345
ClientWidth = 4560
LinkTopic = "Form1"
ScaleHeight = 3660
ScaleWidth = 4560
StartUpPosition = 3 '窗口缺省
Begin ComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 540
Left = 0
TabIndex = 5
Top = 0
Width = 4560
_ExtentX = 8043
_ExtentY = 953
ButtonWidth = 820
ButtonHeight = 794
Appearance = 1
ImageList = "ImageList1"
_Version = 327682
BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7}
NumButtons = 6
BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Back"
Object.ToolTipText = "后退"
Object.Tag = ""
ImageIndex = 1
EndProperty
BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Forward"
Object.ToolTipText = "前进"
Object.Tag = ""
ImageIndex = 2
EndProperty
BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "stop"
Object.ToolTipText = "停止"
Object.Tag = ""
ImageIndex = 3
EndProperty
BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Refresh"
Object.ToolTipText = "刷新"
Object.Tag = ""
ImageIndex = 4
EndProperty
BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Home"
Object.ToolTipText = "主页"
Object.Tag = ""
ImageIndex = 5
EndProperty
BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Search"
Object.ToolTipText = "搜索"
Object.Tag = ""
ImageIndex = 6
EndProperty
EndProperty
End
Begin ComctlLib.ProgressBar ProgressBar1
Height = 255
Left = 2160
TabIndex = 4
Top = 3480
Width = 2295
_ExtentX = 4048
_ExtentY = 450
_Version = 327682
Appearance = 1
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 330
Left = 0
TabIndex = 3
Top = 3330
Width = 4560
_ExtentX = 8043
_ExtentY = 582
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 1
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
EndProperty
EndProperty
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1320
TabIndex = 1
Text = "Combo1"
Top = 720
Width = 3135
End
Begin SHDocVwCtl.WebBrowser WebBrowser1
Height = 2295
Left = 120
TabIndex = 0
Top = 1080
Width = 4335
ExtentX = 7646
ExtentY = 4048
ViewMode = 0
Offline = 0
Silent = 0
RegisterAsBrowser= 0
RegisterAsDropTarget= 1
AutoArrange = 0 'False
NoClientEdge = 0 'False
AlignLeft = 0 'False
ViewID = "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
Location = ""
End
Begin ComctlLib.ImageList ImageList1
Left = 720
Top = 480
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 24
ImageHeight = 24
MaskColor = 12632256
_Version = 327682
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 6
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0000
Key = "Back"
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0692
Key = "Forward"
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0D24
Key = "Stop"
EndProperty
BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":13B6
Key = "Refresh"
EndProperty
BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":1A48
Key = "Home"
EndProperty
BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":20DA
Key = "Search"
EndProperty
EndProperty
End
Begin VB.Label Label1
Caption = "Label1"
Height = 495
Left = 120
TabIndex = 2
Top = 720
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Label1.Caption = "地址URL"
Combo1.Text = ""
Combo1.Top = Label1.Height
Combo1.Left = 0
WebBrowser1.Top = Combo1.Top + Combo1.Height
WebBrowser1.Left = 0
Form_Resize
StatusBar1.Style = sbrSimple
ProgressBar1.ZOrder
End Sub
Private Sub Form_Resize()
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
End Sub
Private Sub WebBrowser1_TitleChange(ByVal Text As String)
Combo1.Text = WebBrowser1.LocationURL
End Sub
Private Sub Combo1_Click()
'转到指定网址
WebBrowser1.Navigate Combo1.Text
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim I As Long
Dim existed As Boolean
If KeyCode = 13 Then
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 WebBrowser1_DownloadBegin()
'下载开始时状态栏显示“Now Linking...”
StatusBar1.SimpleText = "Now Linking..."
End Sub
Private Sub WebBrowser1_DownloadComplete()
'下载完成时状态栏显示“Link Finished”
StatusBar1.SimpleText = "Link Finished"
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 ToolBar1_ButtonClick(ByVal Button As Button)
On Error Resume Next
Select Case Button.Key
Case "Back"
WebBrowser1.GoBack
Case "Forward"
WebBrowser1.GoForward
Case "Refresh"
WebBrowser1.Refresh
Case "Home"
WebBrowser1.GoHome
Case "Search"
WebBrowser1.GoSearch
Case "Stop"
WebBrowser1.Stop
Me.Caption = WebBrowser1.LocationName
End Select
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?