单击 webbrowser html 页面中的链接时显示 VB6 表单

Show VB6 forms when click a link in html page of webbrowser(单击 webbrowser html 页面中的链接时显示 VB6 表单)

本文介绍了单击 webbrowser html 页面中的链接时显示 VB6 表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VB6 WebBrowser,当用户单击 WebBrowser 链接的任何特定链接时,我需要打开一个 vb6 表单,例如

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

在 HTML 中

<html>
<head>
<body>
<a href="--show vb6 form--">Click To show VB6 Form2</a>
</body>
</html>

我不知道该怎么做.我认为有时可以完成第三个文本文件,例如单击链接时会在文本文件中写入类似 002 的代码.

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.

vb 格式的 Timer 会每秒检查一次文件,当计时器检测到文件包含 002 时,它会显示该格式.

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>

然后通过 BeforeNavigate2 事件拦截链接点击,查看 url,如果它匹配 #vb-* 运行您的代码:

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 表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:单击 webbrowser html 页面中的链接时显示 VB6 表单

基础教程推荐