⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 combobox.frm

📁 VB6程序设计参考手册 -独立源码 VB6程序设计参考手册 -独立源码
💻 FRM
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "shdocvw.dll"
Begin VB.Form frmBrowser 
   ClientHeight    =   3795
   ClientLeft      =   -555
   ClientTop       =   345
   ClientWidth     =   5460
   Icon            =   "ComboBox.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3795
   ScaleWidth      =   5460
   ShowInTaskbar   =   0   'False
   WindowState     =   2  'Maximized
   Begin ComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   540
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   5460
      _ExtentX        =   9631
      _ExtentY        =   953
      ButtonWidth     =   820
      ButtonHeight    =   794
      Appearance      =   1
      ImageList       =   "imlIcons"
      _Version        =   327682
      BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} 
         NumButtons      =   5
         BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} 
            Key             =   "Prev"
            Object.ToolTipText     =   "返回"
            Object.Tag             =   ""
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} 
            Key             =   "Next"
            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
      EndProperty
   End
   Begin VB.Frame Frame1 
      Height          =   615
      Left            =   0
      TabIndex        =   3
      Top             =   480
      Width           =   8535
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   1080
         TabIndex        =   5
         Text            =   "Combo1"
         Top             =   240
         Width           =   4095
      End
      Begin VB.Label Label1 
         Caption         =   "地址栏"
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   240
         Width           =   615
      End
   End
   Begin SHDocVwCtl.WebBrowser Web1 
      Height          =   2175
      Left            =   240
      TabIndex        =   2
      Top             =   1320
      Width           =   4815
      ExtentX         =   8493
      ExtentY         =   3836
      ViewMode        =   0
      Offline         =   0
      Silent          =   0
      RegisterAsBrowser=   0
      RegisterAsDropTarget=   1
      AutoArrange     =   0   'False
      NoClientEdge    =   0   'False
      AlignLeft       =   0   'False
      NoWebView       =   0   'False
      HideFileNames   =   0   'False
      SingleClick     =   0   'False
      SingleSelection =   0   'False
      NoFolders       =   0   'False
      Transparent     =   0   'False
      ViewID          =   "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
      Location        =   ""
   End
   Begin ComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   300
      Left            =   0
      TabIndex        =   0
      Top             =   3495
      Width           =   5460
      _ExtentX        =   9631
      _ExtentY        =   529
      SimpleText      =   ""
      _Version        =   327682
      BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
         NumPanels       =   2
         BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Object.Width           =   12347
            MinWidth        =   12347
            TextSave        =   ""
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Style           =   5
            Object.Width           =   7056
            MinWidth        =   7056
            TextSave        =   "19:17"
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Comic Sans MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ComctlLib.ImageList imlIcons 
      Left            =   5400
      Top             =   6120
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   24
      ImageHeight     =   24
      MaskColor       =   12632256
      _Version        =   327682
      BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
         NumListImages   =   5
         BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "ComboBox.frx":030A
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "ComboBox.frx":099C
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "ComboBox.frx":102E
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "ComboBox.frx":16C0
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "ComboBox.frx":1D52
            Key             =   ""
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "frmBrowser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim AppName As String

Private Sub Form_Load()
    AppName = "MyApp"
    Combo1.Text = ""
    '读列表信息
    LoadList
    '访问当前节点
    Web1.Navigate Combo1.Text
End Sub

Private Sub Form_Resize()
    Frame1.Move Me.ScaleLeft, Frame1.Top, Me.ScaleWidth
    If Frame1.Width > Combo1.Left + Label1.Left Then
        'Width 属性不能小于 0
        Combo1.Width = Frame1.Width - Combo1.Left - Label1.Left
    End If
    '修改 Web1 的位置、大小
    Web1.Left = Me.ScaleLeft
    Web1.Top = Frame1.Height + Frame1.Top
    Web1.Width = Me.ScaleWidth
    If Me.ScaleHeight - StatusBar1.Height - Web1.Top > 0 Then
        'Height 属性不能小于 0
        Web1.Height = Me.ScaleHeight - StatusBar1.Height - Web1.Top
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    SaveList '保存列表信息
End Sub

'  工具条命令按钮处理
Private Sub Toolbar1_ButtonClick(ByVal Button As Button)
    On Error GoTo Error '添加错误处理
    
    Select Case Button.Key
        Case "Prev"
          Web1.GoBack
        Case "Next"
          Web1.GoForward
        Case "Stop"
          Web1.Stop
        Case "Refresh"
          Web1.Refresh
        Case "Home"
          Web1.GoHome
    End Select
    '退出子程序
    Exit Sub
Error: '错误处理
    Resume Next '忽略错误,继续执行
End Sub

'  当地址列表框中的地址改变时
Private Sub ChangeList(NewItem As String)
    Dim i As Integer
    
    '如果是列表中第一项,返回
    If NewItem = Combo1.List(0) Then
        Exit Sub
    End If
    '删除列表中相同项
    For i = 1 To Combo1.ListCount - 1
        If NewItem = Combo1.List(i) Then
            Combo1.RemoveItem i '列表中已有相同项
        End If
    Next i
    Combo1.AddItem NewItem, 0 '增加列表项
    Combo1.ListIndex = 0 '设置当前显示项
                
End Sub

Private Sub LoadList()
    Dim i As Integer
    Dim varURLs As Variant ' 存储返回的数组的变量
    
   ' 判断是否存有在注册表中存有记录
    If GetSetting(AppName, "Recent", "RecentURL1") = Empty Then
        Exit Sub
    End If
    
    ' 获得"Recent"主键中的全部键值
    varURLs = GetAllSettings(AppName, "Recent")
  
    ' 添加已有 URL 地址
    For i = 0 To UBound(varURLs, 1)
         Combo1.AddItem varURLs(i, 1)
    Next i
    
    Combo1.ListIndex = 0 '设置列表当前显示
    
End Sub

Private Sub SaveList()
    Dim i As Integer
    Dim Key As String
    
   '判断是否存有文件
    If GetSetting(AppName, "Recent", "RecentURL1") <> Empty Then
        DeleteSetting AppName, "Recent"  '删除 Recent 主键中的全部数据
    End If
    '保存当前列表
    For i = 0 To Combo1.ListCount - 1
        Key = "RecentURL" & i
        SaveSetting AppName, "Recent", Key, Combo1.List(i)
    Next i
End Sub

Private Sub Combo1_Click()
    If Len(Combo1.Text) <= 0 Then
        Exit Sub
    End If
    ChangeList Combo1.Text '改变列表显示
    Web1.Navigate Combo1.Text '开始下载主页
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        Call Combo1_Click
    End If
End Sub

Private Sub Web1_DownloadComplete()
    On Error Resume Next
    Me.Caption = Web1.LocationName
End Sub

'  设置状态栏的值
Private Sub Web1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, _
 Flags As Variant, TargetFrameName As Variant, PostData As Variant, _
Headers As Variant, Cancel As Boolean)
    StatusBar1.Panels(1).Text = "正在连接到 : " + URL
End Sub

Private Sub Web1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    StatusBar1.Panels(1).Text = "当前位置为 : " + URL
End Sub

Private Sub Web1_StatusTextChange(ByVal Text As String)
    StatusBar1.Panels(1).Text = Text
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -