点击webbrowser的html页面中的链接时显示VB6表单 [英] Show VB6 forms when click a link in html page of webbrowser
问题描述
我正在使用VB6 WebBrowser,在这里我需要打开一个VB6表单,当用户点击 WebBrowser
的链接时,如
在HTML中
< html>
< head>
< body>
< a href = - show vb6 form - >点击显示VB6 Form2< / a>
< / body>
< / html>
我不知道该怎么做。我想有时候可以完成第三个文本文件,就像点击链接会在文本文件中写入一个类似于 002
的鳕鱼一样。
而vb格式的Timer会每隔一秒检查一次该文件,当定时器检测到文件中包含 002
它会显示表格。
可以用这种方法做到这一点吗?或者其他什么都可以,但我可以除外?
选择一个更好的命名方案,如:
< a href =#vb-showform2>点击显示VB6 Form2< / a>
< a href =#vb-waffles>华夫饼< / a>
然后通过 BeforeNavigate2
事件拦截链接点击次数,看网址,如果它匹配 #vb - *
运行您的代码:
Private Sub WebBrowserCtrl_BeforeNavigate2(ByVal pDisp As Object,URL As Variant,Flags As Variant,TargetFrameName As Variant,PostData As Variant,Headers As Variant,Cancel As Boolean)
'// get# vb-XXX命令来自url
Dim pos As Long:pos = InStrRev(URL,#vb-)
如果pos然后
取消= True'// stop default导航
URL = Mid $(URL,pos + 4)
选择案例LCase $(URL)
案例showform2:Form2.Show
'...
案例华夫饼:MsgBox华夫饼。
Case Else:MsgBox未知命令& URL
结束选择
结束如果
结束Sub
I am working with VB6 WebBrowser, Here i need to open a vb6 form when user click any particular link of WebBrowser
's link like
In HTML
<html>
<head>
<body>
<a href="--show vb6 form--">Click To show VB6 Form2</a>
</body>
</html>
I do't have any idea how to do it. I thought sometime it can be done a third text file like when the link clicked will write a cod like 002
in a text file.
And the in vb form a Timer will check once a second the file, when timer detect the file contains 002
it will show the form.
Can be do this by this method? or anything else shorter i can except?
Pick a better naming scheme like:
<a href="#vb-showform2">Click To show VB6 Form2</a>
<a href="#vb-waffles">Waffles</a>
Then intercept link clicks via the BeforeNavigate2
event, look at the url and if it matches #vb-*
run your code:
Private Sub WebBrowserCtrl_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
'// get #vb-XXX command from url
Dim pos As Long: pos = InStrRev(URL, "#vb-")
If pos Then
Cancel = True '// stop default navigation
URL = Mid$(URL, pos + 4)
Select Case LCase$(URL)
Case "showform2": Form2.Show
'...
Case "waffles": MsgBox "Waffles."
Case Else: MsgBox "Unknown Command " & URL
End Select
End If
End Sub
这篇关于点击webbrowser的html页面中的链接时显示VB6表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!