VB游览器的问题
我用WebBrowser和ComboBox控件做了个游览器,按有些连接就会弹出IE,我想按下就会弹出自己用VB做的那个游览器还有地址栏里的网址怎么保存啊,我关掉就没有了高...
我用WebBrowser和ComboBox控件做了个游览器,按有些连接就会弹出IE,我想按下就会弹出自己用VB做的那个游览器
还有地址栏里的网址怎么保存啊,我关掉就没有了
高手帮帮忙,有代码在加50分 展开
还有地址栏里的网址怎么保存啊,我关掉就没有了
高手帮帮忙,有代码在加50分 展开
4个回答
展开全部
窗体上放一个WebBrowser1,一个Combo1,一个Command1,一个Command2
代码如下,完全实现了你的两个要求
还多加了一个功能,就是点击Command2的时候,可以删除选中的那个网址
Option Explicit
Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
Private Const SplitWord = vbCrLf
Private Sub Command1_Click()
WebBrowser1.Navigate Combo1.Text
If Combo1.ListIndex < 0 Then
Combo1.AddItem Combo1.Text
End If
End Sub
Private Sub Command2_Click()
With Combo1
If .ListIndex >= 0 Then
If .ListCount > 1 Then
Combo1.RemoveItem .ListIndex
.ListIndex = 0
Else
MsgBox "至少应保留一个网址"
End If
End If
End With
End Sub
Private Sub Form_Load()
Dim s As String, ss() As String
Dim i As Integer
Set Web_V1 = WebBrowser1.Object
s = GetSetting("OldUrl", "OldUrl", "OldUrl", "")
If s <> "" Then
ss = Split(s, SplitWord)
Combo1.Clear
For i = 0 To UBound(ss)
Combo1.AddItem ss(i)
Next
Else
Combo1.AddItem "www.baidu.com"
End If
Combo1.ListIndex = 0
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim i As Integer
Dim s As String
With Combo1
If .ListCount > 0 Then
s = .List(0)
For i = 1 To .ListCount - 1
s = s & SplitWord & .List(.ListIndex)
Next
SaveSetting "OldUrl", "OldUrl", "OldUrl", s
End If
End With
End Sub
Private Sub Web_V1_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
Processed = True
WebBrowser1.Navigate URL
End Sub
代码如下,完全实现了你的两个要求
还多加了一个功能,就是点击Command2的时候,可以删除选中的那个网址
Option Explicit
Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
Private Const SplitWord = vbCrLf
Private Sub Command1_Click()
WebBrowser1.Navigate Combo1.Text
If Combo1.ListIndex < 0 Then
Combo1.AddItem Combo1.Text
End If
End Sub
Private Sub Command2_Click()
With Combo1
If .ListIndex >= 0 Then
If .ListCount > 1 Then
Combo1.RemoveItem .ListIndex
.ListIndex = 0
Else
MsgBox "至少应保留一个网址"
End If
End If
End With
End Sub
Private Sub Form_Load()
Dim s As String, ss() As String
Dim i As Integer
Set Web_V1 = WebBrowser1.Object
s = GetSetting("OldUrl", "OldUrl", "OldUrl", "")
If s <> "" Then
ss = Split(s, SplitWord)
Combo1.Clear
For i = 0 To UBound(ss)
Combo1.AddItem ss(i)
Next
Else
Combo1.AddItem "www.baidu.com"
End If
Combo1.ListIndex = 0
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim i As Integer
Dim s As String
With Combo1
If .ListCount > 0 Then
s = .List(0)
For i = 1 To .ListCount - 1
s = s & SplitWord & .List(.ListIndex)
Next
SaveSetting "OldUrl", "OldUrl", "OldUrl", s
End If
End With
End Sub
Private Sub Web_V1_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
Processed = True
WebBrowser1.Navigate URL
End Sub
展开全部
实现在你的第一个要求Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim frmWB As Form1
Set frmWB = New Form1
frmWB.WebBrowser1.RegisterAsBrowser = True
Set ppDisp = frmWB.WebBrowser1.object
frmWB.Visible = True
End Sub
实现你第二个问题(添加conbol,关闭后将combol的内容保存在d:\1.txt,开时读取d:\1.txt的内容)
Dim s As String
Open "d:\1.txt" For Input As #1
Do
Line Input #1, s
Combo1.AddItem s
Loop Until EOF(1) = True
Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
Open "d:\1.txt" For Output As #1
For i = 0 To Combo1.ListCount - 1
Print #1, Combo1.List(i)
Next
Close #1
End Sub
Dim frmWB As Form1
Set frmWB = New Form1
frmWB.WebBrowser1.RegisterAsBrowser = True
Set ppDisp = frmWB.WebBrowser1.object
frmWB.Visible = True
End Sub
实现你第二个问题(添加conbol,关闭后将combol的内容保存在d:\1.txt,开时读取d:\1.txt的内容)
Dim s As String
Open "d:\1.txt" For Input As #1
Do
Line Input #1, s
Combo1.AddItem s
Loop Until EOF(1) = True
Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
Open "d:\1.txt" For Output As #1
For i = 0 To Combo1.ListCount - 1
Print #1, Combo1.List(i)
Next
Close #1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
http://www.longtengwang.com/softcode/VByuanma/talk/200805/4857.html
看到这个浏览器,相信您一定会与我一样坚定学好VB的决心,太强了.而且是中国人自己做的
下载后,release文件夹中有一个可执行文件,体验一下吧
看到这个浏览器,相信您一定会与我一样坚定学好VB的决心,太强了.而且是中国人自己做的
下载后,release文件夹中有一个可执行文件,体验一下吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
留个QQ或者email 我发个案例给你看看!~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询