Antwise community forums
Error: Interface not supported -2147418113 - Printable Version

+- Antwise community forums (https://forums.antwise.com)
+-- Forum: Antview (https://forums.antwise.com/forumdisplay.php?fid=11)
+--- Forum: Antview for Windows (https://forums.antwise.com/forumdisplay.php?fid=12)
+--- Thread: Error: Interface not supported -2147418113 (/showthread.php?tid=108)



Error: Interface not supported -2147418113 - maddire - 2022-04-11

Hi there. I am currently trialing the control for use within my vb6 application.
Everything is working as it should but I am not able to bind Document.CurrentBrowser = EdgeWebBrowser

My code that I am using is below:

Quote:Private WithEvents Document As AntViewAx.AntViewDocument

Private Sub Form_Load()

Set Document = CreateObject("AntViewAx.AntViewDocument")
EdgeWebBrowser.CreateWebView
EdgeWebBrowser.Navigate "https://leadvault.local/full-player.html"

End Sub

Private Sub MapLocalFolderToHostName()

  Dim Path As String
  Dim HostName As String
 
  Path = "C:\Users\Public\Documents\AntView\Examples\VB\html2"
  HostName = "leadvault.local"
  EdgeWebBrowser.SetVirtualHostNameToFolderMapping HostName, Path, hrakAllow
  EdgeWebBrowser.UserDataFolder = Path

End Sub

Private Sub EdgeWebBrowser_OnExecuteScript(ByVal HResult As Long, ByVal JsonObject As String)
  Dim Json As String
 
  ' Use the Document json decode function to make the result more readable
  Document.CurrentBrowser = EdgeWebBrowser
  Json = Document.DecodeJsonObjectString(JsonObject)
  If Json <> "" Then
    MsgBox Json
  End If
End Sub


If anyone could help, that would be great


RE: Error: Interface not supported -2147418113 - wila - 2022-04-11

Hello,

Thank you for your question.

I can confirm the issue and am looking into it.
Currently still in "scratching behind my ear" phase wondering why it doesn't work in VB6 while this works in VBA and elsewhere.

--
Wil


RE: Error: Interface not supported -2147418113 - maddire - 2022-04-11

No worries, hopefully we can figure out a work around


RE: Error: Interface not supported -2147418113 - wila - 2022-04-12

Hello again,

Sadly I had no time to look into this yesterday as I had another VB6 issue to chase down, but this morning I did manage to find a workaround for your problem.

Whereas it works OK in VBA, it seems like that VB6 does not get the dispatch pointer of the object. Even if you had the dispatch pointer of the object, it does not let you assign that to the CurrentBrowser property which takes the specified interface dispatch pointer.

The workaround I have is twofold.
First, a function has been added to the browser control to expose the dispatch pointer.
Secondly, a new method was created for the document interface so that you can connect the AntView Browser object via that dispatch pointer.
With that, it all seems to work OK in Visual Basic as well.

I will have a test version for you this evening or tomorrow as this afternoon I'm having some time away from the computer  Big Grin

Hope this helps,
--
Wil


RE: Error: Interface not supported -2147418113 - maddire - 2022-04-13

Thanks Wil. Looking forward to using this feature


RE: Error: Interface not supported -2147418113 - wila - 2022-04-13

I have send a private build to test via email.

edit: For others reading this.
In the next release of the control the change needed in the code above looks like this
Code:
Private Sub EdgeWebBrowser_OnExecuteScript(ByVal HResult As Long, ByVal JsonObject As String)
  Dim Json As String

  ' Use the Document json decode function to make the result more readable
  Document.BrowserDispatch (EdgeWebBrowser.IDispatchPointer)
  Json = Document.DecodeJsonObjectString(JsonObject)
  If Json <> "" Then
    MsgBox Json
  End If
End Sub

IOW, the line that starts with Document.CurrentBrowser is replaced with the line starting with Document.BrowserDispatch

Edit2: Originally the property exposing the IDispatch pointer was named "Dispatch" but there was a name clash when using Delphi, so the new property name eventually is IDispatchPointer.
--

Wil