Show VB6 forms when click a link in html page of webbrowser

前端 未结 3 1715
终归单人心
终归单人心 2021-01-21 08:56

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

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-21 09:45

    Pick a better naming scheme like:

    Click To show VB6 Form2
    Waffles
    

    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
    

提交回复
热议问题