Page 2 of 2 FirstFirst 12
Results 41 to 54 of 54

Thread: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium

  1. #41
    Fanatic Member
    Join Date
    Jun 2016
    Location
    España
    Posts
    632

    Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium

    have you made any further progress?

  2. #42

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium

    webview ALSO can use for web ide
    Name:  excel webview.jpg
Views: 1696
Size:  38.9 KB
    Attached Images Attached Images   

  3. #43
    Junior Member
    Join Date
    Dec 2016
    Posts
    22

    Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium

    i see the positive progress ..
    however this code require the (installed) SDK + is limited to x32 due to the usage of the 32 Bit version of WebView2Loader.dll
    In case the goal is e.g usage within Office:
    * did you check office root folder ?
    there is WebView2Host.dll and WebView2Loader.dll (within the correct bitness)
    the first offer the entry CreateOfficeWebView2Environment and *Options (to configure the userfolder, and additional parms)

    Now this Vtbl approach "just" need to be converted into x64 .. with some (conditional) LongPtr conversions and usage of the both within ".\Microsoft Office\root\Office16"

  4. #44

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium

    office64 you can test ,and upload vba code to txt file or save to bas file.
    WebView2Loader have x64 version,and vba also can support

    https://globalcdn.nuget.org/packages....1774.30.nupkg
    (rename to zip file,unzip it)

    Microsoft.Web.WebView2.1.0.1774.30\build\native\x64
    WebView2Loader.dll
    WebView2Loader.dll.lib
    Last edited by xiaoyao; Aug 19th, 2023 at 11:28 AM.

  5. #45
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    481

    Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium

    @yokesee: I don't know if my answer to your private mail went out. Unfortunately, the number of characters is also limited, so I couldn't write everything there. So here again. I have a test project VBC_UwpWebView.zip on activevb.de in the up/download area. This creates a WebViewControl via WinRT. However, this is still based on the older Edge browser and not on WebView2. The WinRT WebViewControl returns the following UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; WebView/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19045. You were concerned with creating multiple browser instances. All you have to do is make a few small changes to the code.
    Code:
    Option Explicit
    
    
    Private IsGetUserAgent As Boolean
    
    
    ' A WebViewControl array would probably be better here.
    Private WithEvents WebViewControl As clsWVC
    Private WithEvents WebViewControl1 As clsWVC ' <- new
    Private WithEvents WebViewControlProcess As clsWVCP
    and
    Code:
    Private Sub Form_Load()
        Me.ScaleMode = vbPixels
        cmdGoBack.Enabled = False
        cmdGoForward.Enabled = False
        Me.Caption = "WinRT-WebView:"
        Call lblInfo.Move(0, Me.ScaleHeight - 15, Me.ScaleWidth, 15)
        
        Set WebViewControlProcess = New clsWVCP
        
        If WebViewControlProcess.Create Then
            Set WebViewControl = WebViewControlProcess.CreateWebViewControlAsync(Me.hWnd, NewRect(0, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50)) ' <- changed
            Set WebViewControl1 = WebViewControlProcess.CreateWebViewControlAsync(Me.hWnd, NewRect(Me.ScaleWidth \ 2, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50)) ' <- new
            
            ' WebViewControl.Scaling = 0.8 '1 = 100%
            
            Dim UriRuntimeClass As New clsURC
            If UriRuntimeClass.CreateUri("https://www.google.de/") Then
                Call WebViewControl.Navigate(UriRuntimeClass)
            End If
        
            ' New
            Dim UriRuntimeClass1 As New clsURC
            If UriRuntimeClass1.CreateUri("https://www.vbforums.com/") Then
                Call WebViewControl1.Navigate(UriRuntimeClass1)
            End If
        
        End If
    End Sub
    
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        WebViewControl1.Closing ' <- new
        WebViewControl.Closing
        WebViewControlProcess.Terminate
        Set WebViewControl1 = Nothing ' <- new
        Set WebViewControl = Nothing
        Set WebViewControlProcess = Nothing
    End Sub
    
    
    Private Sub Form_Resize()
        If Me.WindowState <> vbMinimized Then
            Call lblInfo.Move(0, Me.ScaleHeight - 15, Me.ScaleWidth, 15)
            WebViewControl.bounds = NewRect(0, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50) ' <- changed
            WebViewControl1.bounds = NewRect(Me.ScaleWidth \ 2, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50) ' <- new
        End If
    End Sub
    This creates two WebViewControl instances on the same form (hWnd). You can also use a TabControl where you then assign a WebViewControl instance to each tab.

  6. #46
    New Member
    Join Date
    Dec 2023
    Posts
    6

    Re: vb6 edge webview2 demo by IUnknown,without rc6.dll

    Quote Originally Posted by yokesee View Post
    Code:
    Set WebviewMethodDc = CallWebview2.MethodDictionary
    Set WebviewMethodDc = MethodDictionary
    
    Public Function MethodDictionary() As Dictionary
        Set MethodDictionary = New Dictionary
        MethodDictionary.CompareMode = TextCompare
        MethodDictionary.Add "get_Settings", 1
        MethodDictionary.Add "get_Source", 2
        MethodDictionary.Add "Navigate", 3
        MethodDictionary.Add "NavigateToString", 4
        MethodDictionary.Add "add_NavigationStarting", 5
        MethodDictionary.Add "remove_NavigationStarting", 6
        MethodDictionary.Add "add_ContentLoading", 7
        MethodDictionary.Add "remove_ContentLoading", 8
        MethodDictionary.Add "add_SourceChanged", 9
        MethodDictionary.Add "remove_SourceChanged", 10
        MethodDictionary.Add "add_HistoryChanged", 11
        MethodDictionary.Add "remove_HistoryChanged", 12
        MethodDictionary.Add "add_NavigationCompleted", 13
        MethodDictionary.Add "remove_NavigationCompleted", 14
        MethodDictionary.Add "add_FrameNavigationStarting", 15
        MethodDictionary.Add "remove_FrameNavigationStarting", 16
        MethodDictionary.Add "add_FrameNavigationCompleted", 17
        MethodDictionary.Add "remove_FrameNavigationCompleted", 18
        MethodDictionary.Add "add_ScriptDialogOpening", 19
        MethodDictionary.Add "remove_ScriptDialogOpening", 20
        MethodDictionary.Add "add_PermissionRequested", 21
        MethodDictionary.Add "remove_PermissionRequested", 22
        MethodDictionary.Add "add_ProcessFailed", 23
        MethodDictionary.Add "remove_ProcessFailed", 24
        MethodDictionary.Add "AddScriptToExecuteOnDocumentCreated", 25
        MethodDictionary.Add "RemoveScriptToExecuteOnDocumentCreated", 26
        MethodDictionary.Add "ExecuteScript", 27
        MethodDictionary.Add "CapturePreview", 28
        MethodDictionary.Add "Reload", 29
        MethodDictionary.Add "PostWebMessageAsJson", 30
        MethodDictionary.Add "PostWebMessageAsString", 31
        MethodDictionary.Add "add_WebMessageReceived", 32
        MethodDictionary.Add "remove_WebMessageReceived", 33
        MethodDictionary.Add "CallDevToolsProtocolMethod", 34
        MethodDictionary.Add "get_BrowserProcessId", 35
        MethodDictionary.Add "get_CanGoBack", 36
        MethodDictionary.Add "get_CanGoForward", 37
        MethodDictionary.Add "GoBack", 38
        MethodDictionary.Add "GoForward", 39
        MethodDictionary.Add "GetDevToolsProtocolEventReceiver", 40
        MethodDictionary.Add "Stop", 41
        MethodDictionary.Add "add_NewWindowRequested", 42
        MethodDictionary.Add "remove_NewWindowRequested", 43
        MethodDictionary.Add "add_DocumentTitleChanged", 44
        MethodDictionary.Add "remove_DocumentTitleChanged", 45
        MethodDictionary.Add "get_DocumentTitle", 46
        MethodDictionary.Add "AddHostObjectToScript", 47
        MethodDictionary.Add "RemoveHostObjectFromScript", 48
        MethodDictionary.Add "OpenDevToolsWindow", 49
        MethodDictionary.Add "add_ContainsFullScreenElementChanged", 50
        MethodDictionary.Add "remove_ContainsFullScreenElementChanged", 51
        MethodDictionary.Add "get_ContainsFullScreenElement", 52
        MethodDictionary.Add "add_WebResourceRequested", 53
        MethodDictionary.Add "remove_WebResourceRequested", 54
        MethodDictionary.Add "AddWebResourceRequestedFilter", 55
        MethodDictionary.Add "RemoveWebResourceRequestedFilter", 56
        MethodDictionary.Add "add_WindowCloseRequested", 57
        MethodDictionary.Add "remove_WindowCloseRequested", 58
    End Function


    Hi,I am running a script which allows me to extract information from a website and view it directly in the Google Chrome console. Now I want to extract said information or store it in a variable but I can't find a way since according to what I have consulted I require one of these 3 options but I don't know how to implement it directly in my code since the function declarations do not appear

    this is th script:
    script = "var divsListAds = document.querySelectorAll('.mt-ListAds');" & vbCrLf & _
    "var hrefArray = [];" & vbCrLf & _
    "divsListAds.forEach(function(div) {" & vbCrLf & _
    " var enlaces = div.querySelectorAll('a');" & vbCrLf & _
    " enlaces.forEach(function(enlace) {" & vbCrLf & _
    " hrefArray.push(enlace.getAttribute('href'));" & vbCrLf & _
    " });" & vbCrLf & _
    "});" & vbCrLf & _
    "alert(hrefArray);" & vbCrLf & _
    "window.chrome.webview.postMessage(JSON.stringify(hrefArray));"

    WV.ExecuteScript script


    i need implement this:
    PostWebMessageAsJson"
    "PostWebMessageAsString"
    "add_WebMessageReceived"


    If anyone can help me I would greatly appreciate it.

  7. #47

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: vb6 edge webview demo by IUnknown,without rc6.dll

    Quote Originally Posted by yokesee View Post
    Very good work.
    Is it possible to add extensions?
    thanks
    WebView 2 support extends Part of what WebView 2 has been missing is support for extensions, and today I saw on its github that it already supports extensions APIs: experimental extensions APIs Although it is only a preview function at present, the probability of formal inclusion is still relatively large. Try it when you are free.

    2023-12-11
    https://learn.microsoft.com/en-us/mi...ental-features

    CoreWebView2Profile Class:

    CoreWebView2Profile.AddBrowserExtensionAsync Method
    CoreWebView2Profile.GetBrowserExtensionsAsync Method
    Last edited by xiaoyao; Jan 16th, 2024 at 01:54 AM.

  8. #48
    New Member
    Join Date
    Aug 2024
    Posts
    1

    Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium

    I got a hard time to run the codes in excel x64. Can any one provide a x64 version defination of CreateCoreWebView2EnvironmentWithOptions and a sample code to call? And do I need to put the correct loader into the same folder?

  9. #49
    New Member
    Join Date
    Sep 2024
    Posts
    3

    Re: vb6 edge webview2 demo by IUnknown?without rc6.dll

    Quote Originally Posted by xiaoyao View Post
    add some webviewe method

    Code:
    Function OpenUrl(ByVal Url As String)
        If Left(LCase(Url), 4) <> "http" Then Url = "http://" & Url
        v = VTableCallEx("Navigate", webviewWindow, 3, StrPtr(Url))
    End Function
    
    Function OpenDevToolsWindow()
        v = VTableCallEx("OpenDevToolsWindow", webviewWindow, 49)
    End Function
    
    Function ExecuteScript(JS As String)
      v = VTableCallEx("ExecuteScript", webviewWindow, 27, StrPtr(JS), 0&)
    End Function
    
    Function AddHostObjectToScript(ObjName As String, Obj1 As Object)
      v = VTableCallEx("AddHostObjectToScript", webviewWindow, 47, StrPtr(ObjName), ObjPtr(Obj1))
      AddHostObjectToScript = hResult = 0
    End Function
    
    Function WebReSize() As Boolean
        Dim RECT1 As RECT
        GetClientRect webHostHwnd, RECT1
        'webviewController->put_Bounds(bounds);
        v = VTableCallEx("put_Bounds", webviewController, 4, RECT1.Left, RECT1.Top, RECT1.Right, RECT1.Bottom)
        WebReSize = hResult = 0
    End Function


    HI xiaoyao,

    Very nice work , your solution is very helpful .
    Please help me if possible , in my case i need to get return value/result from javascript function , I tried using ExecuteScript function but no luck .

    Thanks

  10. #50
    New Member
    Join Date
    Sep 2024
    Posts
    11

    Re: vb6 edge webview2 demo by IUnknown?without rc6.dll

    Thanks @xiaoyao
    The demo works well as a simple application with one form but I found two related problems if the code is used with multiple forms.

    1. The form using Webview2 can be opened and used once but if closed and reopened the program crashes. A workaround is to hide the form instead of closing it then show again when required.
    2. For the same reason it is impossible to have more than one form using Webview2. No workaround for this.

  11. #51
    New Member
    Join Date
    Sep 2024
    Posts
    3

    Re: vb6 edge webview2 demo by IUnknown,without rc6.dll

    Hi Xiaoyao

    I request you please provide little more details to get results back from executescript .

  12. #52

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: vb6 edge webview2 demo by IUnknown,without rc6.dll

    Quote Originally Posted by PrashantS View Post
    Hi Xiaoyao

    I request you please provide little more details to get results back from executescript .
    ok,,,,

  13. #53
    New Member
    Join Date
    Sep 2024
    Posts
    3

    Re: vb6 edge webview2 demo by IUnknown,without rc6.dll

    I tried this solution , but unfortunately it is still crashing .

  14. #54
    Junior Member
    Join Date
    Feb 2022
    Posts
    22

    Re: vb6 edge webview2 demo by IUnknown?without rc6.dll

    Quote Originally Posted by PrashantS View Post
    I tried this solution , but unfortunately it is still crashing .
    Not sure if this is of use to anyone, but got this working with the aid of Claude. Now does not crash if closed if running in IDE, or the compiled exe is closed. It will crash if [STOP] pressed within the IDE.
    Attached Files Attached Files

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width