Page 14 of 14 FirstFirst ... 411121314
Results 521 to 555 of 555

Thread: VB6 WebView2-Binding (Edge-Chromium)

  1. #521
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: VB6 WebView2-Binding (Edge-Chromium)

    how to use --disable-web-security??

    can't runjs to frame document.
    Uncaught DOMException: Failed to read a named property 'document' from 'Window': Blocked a frame with origin "https://**.com" from accessing a cross-origin frame.
    at <anonymous>:2:64
    ???? @ VM1604:2

    var iframe = document.querySelector("#pt_iframe");
    error here:
    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;

  2. #522
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Did you try passing the switch to the additionalBrowserArguments parameter on the BindTo method?

    e.g.:

    Code:
          MyWebView2.BindTo MyHwnd, , , , "--disable-web-security"
    ?

  3. #523
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by jpbro View Post
    Did you try passing the switch to the additionalBrowserArguments parameter on the BindTo method?

    e.g.:

    [/code]

    ?
    thank you

    how to get response data by vb6?
    how to
    c# like " var response = await e.Request.GetResponseAsync();"
    how to get all url data ,like fiddler.exe or httpwatch.exe?

    Code:
    private async void InitializeWebView2()
    {
        webView2 = new WebView2();
        webView2.Dock = DockStyle.Fill;
        this.Controls.Add(webView2);
    
        await webView2.EnsureCoreWebView2Async(null);
        webView2.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested;
        webView2.CoreWebView2.Navigate("https://example.com");
    }
    
    private async void CoreWebView2_WebResourceRequested(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestedEventArgs e)
    {
        // ??????
        if (e.Request.Uri.Contains("specific-url-to-monitor"))
        {
            // ??????
            var response = await e.Request.GetResponseAsync();
            var responseStream = await response.GetContentAsync();
            using (var reader = new System.IO.StreamReader(responseStream))
            {
                var responseContent = await reader.ReadToEndAsync();
                // ??????
                Console.WriteLine("Response content: " + responseContent);
            }
        }
    }

  4. #524
    New Member 5501314zt's Avatar
    Join Date
    Nov 2023
    Posts
    2

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Attachment 194487How do I trigger the ?start learning??“????”? button in VB6.0 version webview2?

  5. #525
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    733

    Re: VB6 WebView2-Binding (Edge-Chromium)

    now i have a question

    Code:
    Private Sub WV_DocumentComplete()
    
    WV.jsRunAsync "LoadNextVideo"  'i used this js command to find video ,but Data is not available?
    
    but if i set this command in commandbutton and click ?i wil get the data 
    Private Sub cmdCommand2_Click()
       
            infoLab.Caption = flag
            WV.jsRunAsync "LoadNextVideo"
    End Sub
    why ?

  6. #526
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Perhaps the "data" loads asynchronously after the main document has finished loading? You might need to add a small helper script to look for a specific element that is injected into the DOM asynchronously and then call LoadNextVideo when it is found.

  7. #527
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    733

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by jpbro View Post
    Perhaps the "data" loads asynchronously after the main document has finished loading? You might need to add a small helper script to look for a specific element that is injected into the DOM asynchronously and then call LoadNextVideo when it is found.
    I'm not very proficient in js and don't know how to wait for data asynchronously

    Code:
    Do
                Wait 1000
                Debug.Print flag & "....."
    
                If WV.jsProp("document.querySelector('[class=""videotitle""]').innerText") = "ok" Then
                    Debug.Print "we can se the title of the video?now run LoadNextVideo "
    
                    WV.jsRunAsync "LoadNextVideo"  '
                    
                    Exit Do
                End If
             
            Loop
    Still no data is available
    Last edited by xxdoc123; Jul 18th, 2025 at 07:00 PM.

  8. #528
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    I know Olaf has already advised a way to pull http-only cookies in #440 like below

    Code:
    Private WithEvents WV As cWebView2
    
    Private Sub Form_Load()
      Set WV = New_c.WebView2(hWnd, 0)
    End Sub
    
    Private Sub WV_InitComplete()
      WV.Navigate "http://SomeDomain.com", 0
    End Sub
     
    Private Sub WV_DocumentComplete()
      Debug.Print WV.jsProp("document.cookie")
    End Sub
    
    Private Sub WV_WebResourceResponseReceived(ByVal ReqURI As String, ByVal ReqMethod As String, ByVal RespStatus As Long, ByVal RespReasonPhrase As String, ByVal RespHeaders As RC6.cCollection)
      If RespHeaders.Exists("Set-Cookie") Then Debug.Print RespHeaders("Set-Cookie")
      
    '  Dim i As Long 'alternatively, one can enumerate all response-headers on the JSON-Collection
    '  For i = 0 To RespHeaders.Count - 1
    '    Debug.Print RespHeaders.KeyByIndex(i), RespHeaders.ItemByIndex(i)
    '  Next
    End Sub
    
    Private Sub Form_Resize()
      If Not WV Is Nothing Then WV.SyncSizeToHostWindow
    End Sub
    However, some modern websites (cannot share link) are using different ways to set secure cookies. Hence, they're not accessible the way Olaf recommended in #440. So I tried by directly accessing browser's cookies using following code:
    Code:
    WV.CallDevToolsProtocolMethod "Network.getAllCookies", "{}"
    Problem is that CallDevToolsProtocolMethod does not return anything. So just cannot receive response which I need. So, is there a workaround I could receive response from CallDevToolsProtocolMethod method or an alternate but solid way to pull all the cookies (including http-only ones).

    Thankyou so much!

  9. #529
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,654

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Well the underlying call does return something, through an async event completed interface, the problem with closed source wrappers is you're going to have trouble getting it since the author has vanished. Might be able to figure out a way to get a pointer to the underlying ICoreWebView2 interface to call it yourself

    Code:
       Interface ICoreWebView2 Extends IUnknown
    ...
            Sub CallDevToolsProtocolMethod(ByVal methodName As LongPtr, ByVal parametersAsJson As LongPtr, ByVal handler As ICoreWebView2CallDevToolsProtocolMethodCompletedHandler)
    
        Interface ICoreWebView2CallDevToolsProtocolMethodCompletedHandler Extends IUnknown
            Sub Invoke(ByVal errorCode As Long /* HRESULT */, ByVal result As LongPtr /* LPWSTR */)
        End Interface

  10. #530
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by BilalAhmed View Post
    I
    However, some modern websites (cannot share link) are using different ways to set secure cookies. Hence, they're not accessible the way Olaf recommended in #440. So I tried by directly accessing browser's cookies using following code:
    Code:
    WV.CallDevToolsProtocolMethod "Network.getAllCookies", "{}"
    Problem is that CallDevToolsProtocolMethod does not return anything. So just cannot receive response which I need. So, is there a workaround I could receive response from CallDevToolsProtocolMethod method or an alternate but solid way to pull all the cookies (including http-only ones).

    Thankyou so much!
    If you add the following code to your project:

    Code:
    Private Sub WV_WebResourceResponseReceived(ByVal ReqURI As String, ByVal ReqMethod As String, ByVal RespStatus As Long, ByVal RespReasonPhrase As String, ByVal RespHeaders As RC6.cCollection)
       Debug.Print ReqURI, ReqMethod, RespStatus, RespReasonPhrase, RespHeaders.SerializeToJSONString
    End Sub
    And then call WV.CallDevToolsProtocolMethod "Network.getAllCookies", "{}" do you see any of the cookie data you are looking for in the Immediate window?

  11. #531
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Thank you jpbro, but if you could read my original message, you will notice that I have already tried this event. So to answer your question, unfortunately that doesnt work for me!

    Thank you so much!!!

  12. #532
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Didn't know if you tried it with WV.CallDevToolsProtocolMethod "Network.getAllCookies", "{}", because I see the event fires multiple times and returns a lot of data when calling it against some example sites, but obviously I can't test with your site since you are unable to provide it. Hoped one or more of the firings would include your special Cookie(s).

  13. #533
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    My guess is that WV.CallDevToolsProtocolMethod "Network.getAllCookies", "{}" invokes JSAsyncResult event (only a guess, not really sure). But it doesnt bring anything to "WebResourceResponseReceived" and I think reason is obvious, WebResourceResponseReceived takes care only top level post/get/put/patch requests and listens to them. Whereas CallDevToolsProtocolMethod performs a low level operations and talks directly to the browser (Like selenium does). You're seeing so many calls being fired because several analytics softwares and some JS based sites keep refreshing data on the backend and, that is not possible without making a get/post etc.. requests which WebResourceResponseReceived event captures.

    So to 100% be sure, I carefully tested your code but, without luck!

    Thankyou so much!

  14. #534
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,654

    Re: VB6 WebView2-Binding (Edge-Chromium)

    The method RC6 is wrapping here is ICoreWebView2 -> Sub CallDevToolsProtocolMethod(ByVal methodName As LongPtr, ByVal parametersAsJson As LongPtr, ByVal handler As ICoreWebView2CallDevToolsProtocolMethodCompletedHandler)

    The results are returned to your implementation of ICoreWebView2CallDevToolsProtocolMethodCompletedHandler. RC6 does not look to have a wrapper for that, though I haven't looked too thoroughly-- see if a name like that exists in the events.

    Failing that, see if RC6 allows you to get a pointer to its internal ICoreWebView2 interface; if you can get such a pointer, you can use oleexp.tlb for the interfaces to invoke the command manually to your own implementation of the completion handler.

  15. #535
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Okay Faflone,

    You really sound logical but, unfortunately could not get a hold on anything you recommended. I also tried to see if WV exposes somthing by following 3 functions


    Code:
    Private Sub GetWebView2Pointer()
        Dim rawPtr As Long
        Dim WVPtr As Long
        Dim possibleVTablePtr As Long
        
        ' Step 1: Get pointer to the WV object
        WVPtr = ObjPtr(WV)
        
        ' Step 2: Read the first 4/8 bytes at the object's address
        ' This may be the vtable or a pointer to internal struct
        CopyMemory possibleVTablePtr, ByVal WVPtr, LenB(rawPtr)
    
        ' Print it for inspection
        Debug.Print "WV ObjPtr = &H" & Hex$(WVPtr)
        Debug.Print "First value at WV (possible vtable/internal struct) = &H" & Hex$(possibleVTablePtr)
    
        ' Try also to read 2nd level indirection if necessary:
        Dim possibleWebView2Ptr As Long
        CopyMemory possibleWebView2Ptr, ByVal possibleVTablePtr, LenB(rawPtr)
        Debug.Print "Value pointed by 1st value = &H" & Hex$(possibleWebView2Ptr)
    End Sub
    Private Sub ScanWVMemory()
        Dim baseAddr As Long
        baseAddr = ObjPtr(WV)
        
        Dim i As Long
        Dim Value As Long
        Debug.Print "Scanning memory starting at &H" & Hex$(baseAddr)
        
        For i = 0 To 60 Step 4
            CopyMemory Value, ByVal (baseAddr + i), 4
            Debug.Print "Offset +" & Hex$(i) & ": &H" & Hex$(Value)
        Next i
    End Sub
    Private Sub DumpWVStrings()
        Dim baseAddr As Long
        baseAddr = ObjPtr(WV)
        
        Dim addr As Long
        Dim tmpStr As String
        Dim i As Long
        
        For i = 0 To 200 Step 4
            CopyMemory addr, ByVal baseAddr + i, 4
            If addr > &H10000 And addr < &H7FFFFFFF Then
                On Error Resume Next
                tmpStr = Space$(200)
                CopyMemory ByVal StrPtr(tmpStr), ByVal addr, 200
                Debug.Print "Offset +" & Hex(i) & ": "; Left$(tmpStr, 100)
            End If
        Next i
    End Sub
    But this failed too. All it returned (especially "DumpWVStrings") just garbage

    So probably Olaf may be able to help?

    Thankyou so much!


    Quote Originally Posted by fafalone View Post
    The method RC6 is wrapping here is ICoreWebView2 -> Sub CallDevToolsProtocolMethod(ByVal methodName As LongPtr, ByVal parametersAsJson As LongPtr, ByVal handler As ICoreWebView2CallDevToolsProtocolMethodCompletedHandler)

    The results are returned to your implementation of ICoreWebView2CallDevToolsProtocolMethodCompletedHandler. RC6 does not look to have a wrapper for that, though I haven't looked too thoroughly-- see if a name like that exists in the events.

    Failing that, see if RC6 allows you to get a pointer to its internal ICoreWebView2 interface; if you can get such a pointer, you can use oleexp.tlb for the interfaces to invoke the command manually to your own implementation of the completion handler.

  16. #536
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    If you're looking for an alternative, there's always twinBasic. It comes with an open source(-ish?) WebView2 implementation on top of a closed-source language/compiler that's mostly VB6 compatible. It's getting more compatible by the day and it only costs $35 USD/month, forever. Sure, it’s also a one-man show, but the "one man" is still really active compared to the other "one man", and this time it's different...If either you or he runs out of money, the whole thing just stops working completely

  17. #537
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,654

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Yeah it doesn't seem a method was included to get the pointer that you need, leaving only options not worth the trouble. Might want to use the twinBASIC WebView2 control; if you're not ready to switch to tB I've wrapped it in an ActiveX control that works in VB6/VBA/etc. It comes with an event to receive the results of the call you're looking for by default with no need for modification. Switching to that will be easier than trying to dig out the pointer.

    ---

    If you're looking for an alternative, there's always twinBasic. It comes with an open source(-ish?) WebView2 implementation on top of a closed-source language/compiler that's mostly VB6 compatible. It's getting more compatible by the day and it only costs $35 USD/month, forever. Sure, it’s also a one-man show, but the "one man" is still really active compared to the other "one man", and this time it's different...If either you or he runs out of money, the whole thing just stops working completely
    Maybe I missed the sarcasm but the idea either your code or the tB IDE/compiler just 'stops working completely' because either side runs out of money is absurdly false. There's a free community edition where the only limitation is a splash screen on x64 binaries, and no LLVM optimization (barely any of it implemented yet). As the "free" suggests, this costs $0 per month, not $35 per month. If you do get a premium subscription then stop paying, it just reverts to the community edition. Nothing stops working. And your binaries stay as is, there's no license checks in your code; an exe built with an active subscription will remain splashscreen free forever. If Wayne runs out of money, worst case is tB stays as it is now, already far ahead of VB6 in features and complete enough you can work around bugs and unimplemented parts. And that's if it happens soon before tB leaves Beta. Once it hits v1.0 the source goes into escrow to be released if abandoned.

  18. #538
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by fafalone View Post
    Yeah it doesn't seem a method was included to get the pointer that you need, leaving only options not worth the trouble. Might want to use the twinBASIC WebView2 control; if you're not ready to switch to tB I've wrapped it in an ActiveX control that works in VB6/VBA/etc. It comes with an event to receive the results of the call you're looking for by default with no need for modification. Switching to that will be easier than trying to dig out the pointer.

    ---



    Maybe I missed the sarcasm but the idea either your code or the tB IDE/compiler just 'stops working completely' because either side runs out of money is absurdly false. There's a free community edition where the only limitation is a splash screen on x64 binaries, and no LLVM optimization (barely any of it implemented yet). As the "free" suggests, this costs $0 per month, not $35 per month. If you do get a premium subscription then stop paying, it just reverts to the community edition. Nothing stops working. And your binaries stay as is, there's no license checks in your code; an exe built with an active subscription will remain splashscreen free forever. If Wayne runs out of money, worst case is tB stays as it is now, already far ahead of VB6 in features and complete enough you can work around bugs and unimplemented parts. And that's if it happens soon before tB leaves Beta. Once it hits v1.0 the source goes into escrow to be released if abandoned.
    Ahhh...

    you may be right your proposal Fafalone. But the problem under discussion is a smaller part of a large project (though very important). So it may take ages to port all the project and its dependencies in TB. Though I need the solution real quick but, I think at this moment, I should wait for Olaf's response with the hopes that he will come back soon.

    Thankyou so much!

  19. #539
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,654

    Re: VB6 WebView2-Binding (Edge-Chromium)

    The control I posted is built in tB but for VB6. It compiles an ocx control you'd use in VB6 like any other.

    If you wanted to move the entire project to tB... The code should continue to work as is; tB is backwards compatible with VB6, there are no major rewrites like moving to another language. Ocx controls/dlls your project uses will work too. At most you might need to work around some bugs and a handful of missing capabilities; the only thing to actually rewrite is if you use VB internals hacks, which can be replaced with something simpler e.g. if you have a self-subclass think, tB supports AddressOf on class members so you'd just need a simple SetWindowSubclass call.

    Olaf hasn't been heard from in months now so the odds he'll return soon and quickly make a new RC6 version with the feature you want aren't great.

  20. #540
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by fafalone View Post
    Maybe I missed the sarcasm but the idea either your code or the tB IDE/compiler just 'stops working completely' because either side runs out of money is absurdly false. There's a free community edition where the only limitation is a splash screen on x64 binaries, and no LLVM optimization (barely any of it implemented yet). As the "free" suggests, this costs $0 per month, not $35 per month. If you do get a premium subscription then stop paying, it just reverts to the community edition. Nothing stops working. And your binaries stay as is, there's no license checks in your code; an exe built with an active subscription will remain splashscreen free forever. If Wayne runs out of money, worst case is tB stays as it is now, already far ahead of VB6 in features and complete enough you can work around bugs and unimplemented parts. And that's if it happens soon before tB leaves Beta. Once it hits v1.0 the source goes into escrow to be released if abandoned.
    You did miss some sarcasm

    That said, unless I've misunderstood something, you can't build new stuff, fix old stuff, or release updates unless you keep paying the monthly fee indefinitely. A splash screen might be fine for hobby projects, but not much else.

    If Wayne runs out of money tomorrow, does the tB IDE keep running at your current license level forever, or are you out of luck?

    Quote Originally Posted by fafalone View Post
    Once it hits v1.0 the source goes into escrow to be released if abandoned.
    That's the promise, but there's no way to know if it will actually be kept, nor if it will be able to be independently verified should it ever come into play (again, unless I've missed something).

    For the record, I've had a yearly pro subscription to tB since the first or second month it was offered, and I've "bought Wayne a coffee" every month since that option was added too. I've been a financial supporter of tB from early on, and I genuinely believe it's the best shot we've ever had at true VB6 successor.

    But I also think it's a risky proposition for non-hobbyist development at this stage. And if we're being intellectually honest, the same arguments that have been/are being used against RC6 can and should be applied to tB as well.

  21. #541
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Okay, can you compile the ocx for me and upload somewhere to download? I dont mind paying $35 through credit card (probly one month subscription fee for TB).

    Thankyou so much!

  22. #542
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,654

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by jpbro View Post
    You did miss some sarcasm

    That said, unless I've misunderstood something, you can't build new stuff, fix old stuff, or release updates unless you keep paying the monthly fee indefinitely. A splash screen might be fine for hobby projects, but not much else.

    If Wayne runs out of money tomorrow, does the tB IDE keep running at your current license level forever, or are you out of luck?



    That's the promise, but there's no way to know if it will actually be kept, nor if it will be able to be independently verified should it ever come into play (again, unless I've missed something).

    For the record, I've had a yearly pro subscription to tB since the first or second month it was offered, and I've "bought Wayne a coffee" every month since that option was added too. I've been a financial supporter of tB from early on, and I genuinely believe it's the best shot we've ever had at true VB6 successor.

    But I also think it's a risky proposition for non-hobbyist development at this stage. And if we're being intellectually honest, the same arguments that have been/are being used against RC6 can and should be applied to tB as well.
    You could ask about what happens to licenses if there's no more server... I'm not sure that it's even an issue right now; I'm sure there's some reasonable solution. But this isn't an issue unique to tB or to single developers... I'd argue that big corps are *more* likely to rug pull existing products and license servers in a way that forces customers off old products. There's certainly room to argue over details of escrow terms which haven't been discussed yet, but I'd be very surprised if that wasn't done at all, since it would be both an AH move and bad for tB's success, neither of which sound like something Wayne would do.

    Some of the same arguments apply but it's not intellectually honest to pretend there's not both material differences as well as an entirely different degree of how inconvenient alternatives are. RC6 is easy to not use. With tB, your only option that's not "throw out everything and start from scratch" is continuing with vb6, which is itself a risky proposition, given Microsoft already starting to end VBScript support. This topic we're on illustrates the other part: world of difference working around a missing feature in something like rc6 vs something as flexible as a programming language.

  23. #543
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,654

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by BilalAhmed View Post
    Okay, can you compile the ocx for me and upload somewhere to download? I dont mind paying $35 through credit card (probly one month subscription fee for TB).

    Thankyou so much!
    https://github.com/fafalone/ucWebView2

    Open the ucWebView2 project in the .zip with twinBASIC (run as admin so it registers in HKLM where vb6 can see it) and click File->Build.

  24. #544
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by fafalone View Post
    https://github.com/fafalone/ucWebView2

    Open the ucWebView2 project in the .zip with twinBASIC (run as admin so it registers in HKLM where vb6 can see it) and click File->Build.
    fafalone, seems a good product (ucWebview). But I need a vb6 based sample project to understand it and learn good use of events/methods and properties. Can you please have me the link to it?

    Thankyou so much!

  25. #545
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Honestly, I could not even make it open google.com. If I do .navigate method on form load, it says "not ready yet". After an hour of struggle I found out that I cannot draw the control right on the form. Rather, I need to add a picturebox first and then draw the webview control over it.

    to summarize, there are so many precautions and things to consider to make it work. So a sample project which explains:

    1. Initialize the control and navigate to the page
    2. Get document content
    3. Access cookies (both secure and non secure)
    4. Make a devtoolprotocol call and receive response
    5. Manipulate DOM (fill forms, click buttons, set value to the text boxes, click ratio buttons etc)

    I may have more questions but, atleast I should be able to make it run at first.

    Thankyou so much!

  26. #546
    New Member
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by fafalone View Post
    https://github.com/fafalone/ucWebView2

    Open the ucWebView2 project in the .zip with twinBASIC (run as admin so it registers in HKLM where vb6 can see it) and click File->Build.
    BUG: you cannot implement consume "webresourcerequested, navigationstarting" because it says "User defined type not defined"
    Similarly, JSAsyncResult, DownloadItemInterrupted, DownloadCompleted cannot be implemented in VB6 because it is restricted here.

    Apparently seem lots of bugs even though I am still unable to open my first page with this control.

    Thankyou so much!

  27. #547
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by fafalone View Post
    You could ask about what happens to licenses if there's no more server... I'm not sure that it's even an issue right now;
    I could, but I'd rather Wayne focus on the core than me bothering him about licensing server stuff...Again, I'm not trying to throw shade, but licensing *anything* from a one man show is a risk, even more so I think when it is a programming language compared to an add-on library. There will be nowhere to go with your codebase if tB goes belly up. That is a distinct difference compared to VB6+RC6 (or any other 3rd part closed source library) that will basically just keep working forever (albeit with whatever bugs are already baked into it, and limitations of the host language). Neither VB6 nor RC6 have any kind of active licensing system as a dependency, they just work (and will continue to just work essentially forever now with virtualization/emulation layers).

    Quote Originally Posted by fafalone View Post
    I'm sure there's some reasonable solution.
    I'm not so sure...if money runs out, will Wayne care to maintain the licensing server or release a patch to disable license checks? Maybe, maybe not.

    Quote Originally Posted by fafalone View Post
    But this isn't an issue unique to tB or to single developers... I'd argue that big corps are *more* likely to rug pull existing products and license servers in a way that forces customers off old products.
    Sure, but I'm talking about one man shows. Microsoft rug pulled as best they could, but many of us are still here using VB6 despite their attempts.

    Quote Originally Posted by fafalone View Post
    There's certainly room to argue over details of escrow terms which haven't been discussed yet, but I'd be very surprised if that wasn't done at all, since it would be both an AH move and bad for tB's success, neither of which sound like something Wayne would do.
    I agree that it would be a bad move, but at this stage it's just words. Not much different than Olaf's words about his own VB6 successor over the years.

    Quote Originally Posted by fafalone View Post
    Some of the same arguments apply but it's not intellectually honest to pretend there's not both material differences as well as an entirely different degree of how inconvenient alternatives are. RC6 is easy to not use. With tB, your only option that's not "throw out everything and start from scratch" is continuing with vb6, which is itself a risky proposition, given Microsoft already starting to end VBScript support. This topic we're on illustrates the other part: world of difference working around a missing feature in something like rc6 vs something as flexible as a programming language.
    RC6 and tB are totally different things IMO - RC6 is a library/add-on to VB6 that extends it in useful ways. tB is a new language/compiler that is a superset of VB6 that extends it in (probably more) useful ways. Difference is, that the more you adopt tB's "extensions", the more you get tied to tB forever, much in the same way that the more I used VB6, the more I got tied to VB6 forever. The difference is that VB6 is here and will be here for ever (at least in the manner I'm using it). tB is still at a very high risk stage, and IMO there's a significant chance that any work done to migrate code from VB6 to tB will be wasted. I'm not saying people shouldn't take that risk after evaluating all the options, but I do think it would be foolish to believe there isn't a significant risk.

  28. #548
    New Member
    Join Date
    Nov 2020
    Posts
    7

    Re: VB6 WebView2-Binding (Edge-Chromium)

    How could I use the following properties as detailed here

    IsPasswordAutosaveEnabled
    IsGeneralAutofillEnabled

  29. #549
    Addicted Member
    Join Date
    May 2022
    Posts
    144

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Hi all, a little question i can't see asked/solved.

    I'm creating a web on a string.
    I'm using the webview2 like this:
    Code:
     PicWv.Visible = True
        
        Set WV = New_c.WebView2
        If WV.BindTo(PicWv.hwnd) = 0 Then
        MsgBox "No puedo Inicializar el Webview", vbCritical, "Error!"
            Exit Sub
        End If
    generating the web and launching this way:

    WV.NavigateToString laweb

    Everything is working fine, BUT i need to show another web (basically the same web with another data on it (diferent charts)), and then becomes the problem... the web is not reloading... i tried to modify the web content, destroying the WV, but nothing... always the same web until i close the form and launch again with the other data.... any idea about how to solve this ?

    Thanks!

  30. #550
    Addicted Member
    Join Date
    May 2022
    Posts
    144

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Hi all, solved!

    the problem was:

    i was using this code in a button:

    Code:
    Set WV = New_c.WebView2
    
    If WV.BindTo(PicWv.hwnd) = 0 Then
          MsgBox "No puedo Inicializar el Webview", vbCritical, "Error!"
          Exit Sub
    End If
    And everytime i pushed the button i was creating a new WV version...

    Just solved with:

    Code:
        If WV Is Nothing Then
            Set WV = New_c.WebView2
            If WV.BindTo(PicWv.hwnd) = 0 Then
                MsgBox "No puedo Inicializar el Webview", vbCritical, "Error!"
                Exit Sub
            End If
        End If
    Thanks!

  31. #551
    New Member
    Join Date
    Nov 2021
    Posts
    8

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Dear Schmidt,

    I got the following error when I try to reach the URL

    http://www.muzayedeapp.com/muzayede-evleri-icin

    "This browser doesn't support the API's required to use the Firebase SDK"

    Is there a way to bypass this error?

    Thank you for your extremely valuable implementation and help.

    Talat Oncu

  32. #552
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by talatoncu View Post
    I got the following error when I try to reach the URL

    http://www.muzayedeapp.com/muzayede-evleri-icin

    "This browser doesn't support the API's required to use the Firebase SDK"
    Firebase is only supported on HTTPS websites. See: https://stackoverflow.com/a/70750307

    Quote Originally Posted by talatoncu View Post
    Is there a way to bypass this error?
    Change your URL from HTTP to HTTPS: httpS://www.muzayedeapp.com/muzayede-evleri-icin and it should work.

  33. #553
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Should also mention that you should use HTTPS in general these days. Not just for security, but also because a lot of stuff will be broken when using HTTP.

  34. #554
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,167

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Here is how to reimplement missing TitleChange event as raised by the venerable built-in WebBrowser control.

    Code:
    Private WithEvents m_oWebView   As RC6.cWebView2
    
    Private Sub m_oWebView_InitComplete()
        m_oWebView.AddScriptToExecuteOnDocumentCreated "var observer = new MutationObserver(function() { vbH().RaiseMessageEvent('title_change', document.title); });" & vbCrLf & _
            "document.addEventListener('DOMContentLoaded', function() { observer.observe(document.querySelector('title'), { childList: true }); vbH().RaiseMessageEvent('title_change', document.title); }); "
    End Sub
    
    Private Sub m_oWebView_JSMessage(ByVal sMsg As String, ByVal sMsgContent As String, oJSONContent As RC6.cCollection)
        If sMsg = "title_change" Then
            DebugPrint "New title is " & sMsgContent
        End If
    End Sub
    This should be possible to be exposed as a sorely missing separate event on cWebView2 directly using ICoreWebView2::add_DocumentTitleChanged callback but until then using JS to setup MutationObserver on title element after DOMContentLoaded event is fired seems to be good enough workaround.

    cheers,
    </wqw>

  35. #555
    Addicted Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    134

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by wqweto View Post
    Here is how to reimplement missing TitleChange event as raised by the venerable built-in WebBrowser control.

    Code:
    Private WithEvents m_oWebView   As RC6.cWebView2
    
    Private Sub m_oWebView_InitComplete()
        m_oWebView.AddScriptToExecuteOnDocumentCreated "var observer = new MutationObserver(function() { vbH().RaiseMessageEvent('title_change', document.title); });" & vbCrLf & _
            "document.addEventListener('DOMContentLoaded', function() { observer.observe(document.querySelector('title'), { childList: true }); vbH().RaiseMessageEvent('title_change', document.title); }); "
    End Sub
    
    Private Sub m_oWebView_JSMessage(ByVal sMsg As String, ByVal sMsgContent As String, oJSONContent As RC6.cCollection)
        If sMsg = "title_change" Then
            DebugPrint "New title is " & sMsgContent
        End If
    End Sub
    This should be possible to be exposed as a sorely missing separate event on cWebView2 directly using ICoreWebView2::add_DocumentTitleChanged callback but until then using JS to setup MutationObserver on title element after DOMContentLoaded event is fired seems to be good enough workaround.

    cheers,
    </wqw>
    Thanks Wqweto for this tip!
    Happy holidays!

Page 14 of 14 FirstFirst ... 411121314

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