Contents - Index - Top


OnFrameCreated

Interface AntView 

 

Type: Event

Parameters: AntViewFrame Frame

 

 

OnFrameCreated is raised when an iframe is created in the html document that is hosted by the WebView2 control.

This is a reference counted ActiveX object, which means that the object is out of scope (destroyed) if you don't assign it to another object by the end of this event.

 

You can interact directly with the iframe via the Frame variable, or via the AntViewDocument interface after connecting the IDispatchPointer of the frame object to the document. 

Assigning the frame object to a AntViewDocument object will keep the object in scope as well.

 

Example code for attaching a frame object in VB6:

Public WithEvents IFrame As AntViewAx2.AntViewFrame

 

Private Sub EdgeWebBrowser_OnFrameCreated(ByVal Frame As AntViewAx2.IAntViewFrame)

    If Frame.name = "iframeResult" Then

      Set IFrame = Frame

    End If

End Sub

 

Private Sub Form_Load()

    EdgeWebBrowser.CreateWebView

    EdgeWebBrowser.EventsUseHexadecimal = True ' For VB we need to use the Hexadecimal event variants

    Set IFrame = CreateObject("AntViewAx2.AntViewFrame", "")

 

    EdgeWebBrowser.Navigate "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_target"

End Sub

 

Private Sub IFrame_OnNavigationCompletedHex(ByVal IsSuccess As Boolean, ByVal WebErrorStatus As AntViewAx2.TxWebErrorStatus, ByVal NavigationIdHex As String)

  Debug.Print "IFrame loaded"

End Sub

 

If you want to run a script in the iframe or get data from the iframe, then you can attach a document object to the iframe.

 

An example of retrieving the html in an iframe is this:

Option Explicit

Public WithEvents Document As AntViewAx2.AntViewDocument

Public WithEvents FrameDoc As AntViewAx2.AntViewDocument

 

 

Private Sub Form_Initialize()

    Set Document = New AntViewAx2.AntViewDocument

    Document.BrowserDispatch EdgeWebBrowser.IDispatchPointer

 

    Set FrameDoc = New AntViewAx2.AntViewDocument

    EdgeWebBrowser.EventsUseHexadecimal = True

    EdgeWebBrowser.UnlockControl "ExampleCompany", "WI5PO2-2KSU3Q-HWFXFU-IUMU2V-QF8P2F"

End Sub

 

Private Sub Form_Load()

    EdgeWebBrowser.Navigate "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_target"

End Sub

 

Private Sub FrameDoc_OnRequestCurrentHtml(ByVal Html As String)

    Debug.Print Html

End Sub

 

Private Sub EdgeWebBrowser_OnFrameCreated(ByVal Frame As AntViewAx2.IAntViewFrame)

    If Frame.Name = "iframeResult" Then

        FrameDoc.FrameDispatch Frame.IDispatchPointer

        FrameDoc.RequestCurrentHtml

    End If

End Sub

 

As you can see, you can have multiple document objects active at the same time.

Although you can switch your document object between main html view and iframe, it might be better to keep them separated.

 

Introduced in AntView release 1.1.200

 


AntView - The MS Edge WebView2 ActiveX control Date last changed: 09/30/2024