Results 1 to 23 of 23

Thread: VB6 WebView2-Binding (Edge-Chromium)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,007

    VB6 WebView2-Binding (Edge-Chromium)

    Have just finished a Binding to the new WebView2-BrowserControl (based on Edge-Chromium).

    I've included this Binding (all in a single Class, named cWebView2) in the new RC6-version of the RichClient-lib
    (please download this new version 6 from its usual place, at vbRichClient.com first).

    The new BaseDll-package of the RC6 now includes the official WebView2Loader.dll (version 1.0.674),
    which the cWebView2-class then works against.

    Please note, that the above Binding will currently require, that you install the larger:
    "Evergreeen WebView2-Runtime" (not included in the RC6-BasePackage).
    Here the official MS-DownloadLink for the evergreen-installer: https://go.microsoft.com/fwlink/p/?LinkId=2124703

    So, after ensuring the mentioned two prerequisites:
    - the Dlls of the new RC6-package in a folder of your choice + a registered RC6.dll
    - and the successfull installation of the "evergreen-WebView2-runtime" via the MS-download-link above

    You should now be able to test this new Edge-Browser-Binding (even on Win7-OSes) via this little VB6-Demo:
    WebView2Demo.zip

    Please let me know, when something is not working as expected -
    or when you want me to include a certain extra-functionality into the new cWebView2-class.

    I want to "finalize" the new RC6-functionality at the end of the year (then switching Binary-Compatibility on).

    Happy testing...

    Olaf

  2. #2
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    449

    Re: VB6 WebView2-Binding (Edge-Chromium)

    VERY GOOD,HOW TO get web page cookie? so i can use winhttp or xmlhttp to download URL
    OR WebView2Loader.dll WILL have a method for download url,post data?

  3. #3
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    449

    Re: VB6 WebView2-Binding (Edge-Chromium)

    CodeName=Mozilla
    MinorVersion=undefined
    Name=Netscape
    Version=5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36 Edg/86.0.622.58
    CookieEnabled=true

    how to test web page,its chrome or ie?
    https://www.w3school.com.cn/tiy/t.asp?f=hdom_navigator

  4. #4
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    449

    Re: VB6 WebView2-Binding (Edge-Chromium)

    HOW TO RUN JS CALL BY WEB page like :var a=btn1_click(22,33)?
    i want to call vb sub from js,and back the value to js

    Code:
        WV.AddScriptToExecuteOnDocumentCreated "function btn1_click(msg1,msg2){ vbH().RaiseMessageEvent('btn1_click',msg1+','+msg2) }"
    
    WV.NavigateToString "<!DOCTYPE 
    
    html><html><head><title>AppTitle</title></head><body>" & 
    
    _
                              "<div>Hello World...</div>" & _
                              "<input id='txt1' value='foo'>" & _
                              "<button id='btn1' onclick='btn1_click(22,33)' 
    
    >Button1</button>" & _
                          "</body></html>"
    Private Sub WV_JSMessage(ByVal sMsg As String, ByVal 
    
    sMsgContent As String, oJSONContent As cCollection)
    sMsgContent=22,33
    Last edited by xiaoyao; Nov 2nd, 2020 at 09:21 AM.

  5. #5
    New Member
    Join Date
    Aug 2020
    Posts
    7

    Re: VB6 WebView2-Binding (Edge-Chromium)

    (From dm)

    I tested WebView2Demo and it's great. I have some questions:

    (1) Could you add IndexByItem to RC6.cCollection?

    (2) Can WebView.CapturePreview capture the entire Web page, not just the visible part of the window?

    (3) Could you demonstrate the drag operations of WebView, for example: Drag a button or grid from the VB6-Form to WebView, and WebView will generate a Html-Button or a Html-Table in the Web page. Similar to the following: https://www.layoutit.com/build

    (4) Can V8 be integrated into RC6?

    (5) If V8 is too large, can RC6 integrate a small embedded JavaScript engine similar to QuickJS or MuJS?

    (6) When we use VB6 to develop commercial controls, .NET developers are not willing to use VB6 controls, they prefer to use .NET controls. When we use VB6 to develop commercial software, our commercial software can only run on the Windows platform, while our competitors' products can run on multiple platforms (Windows, Web, Android, iOS). In other words, we don't know what we can do with VB6 now? If RC6 could help developers in cross-platform, it would be a very wonderful thing.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,007

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by xiaoyao View Post
    HOW TO get web page cookie?
    The WebView2-interfaces do not include (other than the old, IE-based WebControl)
    a COM-Wrapper-ObjectModel for interaction with the DOM of a loaded document.

    So, all the interaction with a currently loaded DOM has to happen via JavaScript.
    That's the reason, why:
    - jsProp(...)
    - jsRun(...)
    - jsRunAsync(...)
    are included as Methods behind the WV-variable (of type cWebView2).

    And in case of Cookies, that means, you will have to address them via the appropriate js-expression like this:
    Code:
    'enhance the Forms WebView-EventHandler below about an additional line, to read a given documents cookies
    'when pressing the < Navigate to google.com > Button, you should see the cookies which were set from the Google-Server.
    Private Sub WV_DocumentComplete()
      Debug.Print "WV_DocumentComplete"
      Debug.Print WV.jsProp("document.cookie")
    End Sub
    As for your BrowserVersion-String - the one you've posted:
    ...Version=5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36 Edg/86.0.622.58
    does contain a "Chromium-Version-Part" and an "Edge-Version-Part" as well... (so it's definitely not IE-based)

    Olaf

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,007

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by SearchingDataOnly View Post
    (1) Could you add IndexByItem to RC6.cCollection?
    This is already implemented (via Optional ByRef Param: FoundItemIndex) in the cCollection.ItemExists(...) method.

    Quote Originally Posted by SearchingDataOnly View Post
    (2) Can WebView.CapturePreview capture the entire Web page, not just the visible part of the window?
    One could determine (via JavaScript) the "total Height in Pixels" a Document would fit into
    (whilst having a certain PixelWidth) - and then manually resize the WebView (via WV.Movexxx) temporarily,
    and then call the Capture-Method.

    But this feature-request came up also in the "Issue-tracker" IIRC, so I'd like to wait for the official release.

    Quote Originally Posted by SearchingDataOnly View Post
    (3) Could you demonstrate the drag operations of WebView, for example: Drag a button or grid from the VB6-Form to WebView, and WebView will generate a Html-Button or a Html-Table in the Web page. Similar to the following: https://www.layoutit.com/build
    As already statet, one has to incorporate ones own js-snippets into the WebView2-Control,
    to address such actions.
    As e.g. shown here: https://www.w3schools.com/html/html5_draganddrop.asp

    Quote Originally Posted by SearchingDataOnly View Post
    (4) Can V8 be integrated into RC6?
    With the WebView2-Binding, one already has access to the V8-js-engine (it is included via Chromium within this new Edge-based Control).

    Quote Originally Posted by SearchingDataOnly View Post
    (5) If V8 is too large, can RC6 integrate a small embedded JavaScript engine similar to QuickJS or MuJS?
    I'd think that JScript9 (via cActiveScript) is already a "small and relatively fast" js-Engine one can use -
    and as said, for V8-support, one can use the WebView2 (e.g. hosted-in/bound-to an invisible PicBox).

    Quote Originally Posted by SearchingDataOnly View Post
    (6) When we use VB6 to develop commercial controls, .NET developers are not willing to use VB6 controls, they prefer to use .NET controls. When we use VB6 to develop commercial software, our commercial software can only run on the Windows platform, while our competitors' products can run on multiple platforms (Windows, Web, Android, iOS). In other words, we don't know what we can do with VB6 now? If RC6 could help developers in cross-platform, it would be a very wonderful thing.
    That depends on, when a VB6-compatible compiler becomes available.
    My spare-time is not sufficient, to drive this side-project of mine along in a decent pace currently.

    Meanwhile others might come up with "something promising" in this regard -
    but the timeframe will in either case be measured in years, not months.

    Olaf

  8. #8
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    278

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Hi Olaf, I couldn't make it run

    Err Number -2147221164 Clase no registrada

    Set WV = New_c.WebView2 'create the instance

    what am I doing wrong?
    i think i can't register rc6.dll, but if i can load it to project
    leandroascierto.com Visual Basic 6 projects

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,007

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by LeandroA View Post
    what am I doing wrong?
    i think i can't register rc6.dll, but if i can load it to project
    I think, that's what you need to resolve first.
    Just loading the typelib of the RC6 (semiautomatically... via the VB6-IDE),
    will not be enough (on a developer-machine).

    You'll have to:
    - keep any of the Dlls of the RC6-BasePackage-Dlls "in one place" (a single Folder you copy them to, as e.g. C:\RC6\)
    - and then "deep-register" the RC6.dll there either via the included VBScript or via an Admin-Console calling regsvr32 behind the SysWow64 folder

    HTH

    Olaf

  10. #10
    New Member
    Join Date
    Aug 2020
    Posts
    7

    Re: VB6 WebView2-Binding (Edge-Chromium)

    (From dm)

    Quote Originally Posted by Schmidt View Post
    This is already implemented (via Optional ByRef Param: FoundItemIndex) in the cCollection.ItemExists(...) method.
    Yes, in many cases, cCollection.ItemExists and FoundItemIndex are more convenient. But IndexByItem is more concise and intuitive, it's very necessary to add IndexByItem to cCollection.

    Quote Originally Posted by Schmidt View Post
    I'd think that JScript9 (via cActiveScript) is already a "small and relatively fast" js-Engine one can use -
    and as said, for V8-support, one can use the WebView2 (e.g. hosted-in/bound-to an invisible PicBox).
    cActiveScript does not seem to support some of the latest JS syntax and the latest RE parameters.

    Quote Originally Posted by Schmidt View Post
    That depends on, when a VB6-compatible compiler becomes available.
    My spare-time is not sufficient, to drive this side-project of mine along in a decent pace currently.
    If a programming language wants to gain long-term vitality, it must have good commercial value, so as to form a stable software ecological chain around this programming language. If RC5/RC6 users can develop some valuable commercial software around RC6, then you will have more resources (funds and teams) to speed up the development of VB6-compatible compiler. I don't know if you have had such a plan.

    I can develop some good commercial software with VB6 and RC5/RC6, but the problem is that if a commercial software can only run in a Windows environment, its market demand and market share will be very low. Such softwares cannot form a solid software ecological chain, nor can they provide you with more resources.

    Quote Originally Posted by Schmidt View Post
    Meanwhile others might come up with "something promising" in this regard -
    but the timeframe will in either case be measured in years, not months.
    A few years is too long.
    I'm thinking, if we develop a scripting language compatible with the syntax of the BASIC language, and then develop a scripting language runtime environment similar to NodeJS. Is it possible to realize a VB6-like programming language that can be cross-platform? Of course, this scripting language must have a visual IDE similar to VB6.
    Last edited by SearchingDataOnly; Nov 3rd, 2020 at 12:18 PM.

  11. #11
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,964

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Check RadBasic, Mercury VB, B4X
    But this has nothing to do with this code submission

  12. #12
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,409

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by SearchingDataOnly View Post
    A few years is too long..
    Like everyhting in life a new VB compiler will take enough time, patience and disposable income. Judging by the expressed lack of time *and* obvious lack of patience you must be in posession of a lot of disposable income.

    Is there something that interested parties must know here?

    cheers,
    </wqw>

  13. #13
    New Member
    Join Date
    Aug 2020
    Posts
    7

    Re: VB6 WebView2-Binding (Edge-Chromium)

    A small question about WebView2Demo:

    After starting the computer, when opening WebView2Demo.exe or WebView2Demo.vbp for the first time, the system prompts "couldn't initialize Webview-Bingding". After closing the window and re-opening WebView2Demo.exe or WebView2Demo.vbp, the system runs normally.

    In other words, every time the computer is restarted, the first initialization (WV.BindTo) always fails, and the second time is normal.

    In addition, how does IE-WebBrowser achieve a function similar to WebView2.CapturePreview?

    (OS: Win10)

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,007

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by SearchingDataOnly View Post
    ...every time the computer is restarted, the first initialization (WV.BindTo) always fails, and the second time is normal.
    The BindTo (as well as the two Navigate-Methods) have a second (optional)TimeOutSeconds-Parameter -
    by default sitting at 5 seconds.

    I guess your system is (shortly after booting) still quite busy with delayed loading of other base-stuff like services etc. -
    in addition to loading the quite large Chromium-Runtime, ... so the default of 5sec may be a bit too short -
    (I can imagine, that older magnetic disks might play a role, because I see no larger delay here on my test-OSes on SSDs).

    You could:
    - either try to increase that TimeOut-Param (to maybe 10sec or so)
    - or set it to Zero, to tell the methods to wait for their matching EventHandlers
    .. (WV_InitComplete or WV_NavigationCompleted respectively, to proceed with your own, now async Inits from within those Handlers)

    Quote Originally Posted by SearchingDataOnly View Post
    In addition, how does IE-WebBrowser achieve a function similar to WebView2.CapturePreview?
    You still planning on using the IE further???

    Well, there's an IHTMLPainter interface one can cast to (IIRC, from an IHTMLWindow2), which offers a Draw-method.
    There's also PrintPreview-interfaces which allow capturing of one (or more) pages.
    And of course you could try to work via API-calls directly on the hWnd of that Control, to copy its current Render-Output.

    Perhaps there's also some stuff hidden in all those IE-OleCmdID-EnumValues which might accomplish a Preview- or Capture-output.

    Olaf

  15. #15
    New Member
    Join Date
    Aug 2020
    Posts
    7

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by Schmidt View Post
    The BindTo (as well as the two Navigate-Methods) have a second (optional)TimeOutSeconds-Parameter -
    by default sitting at 5 seconds.

    I guess your system is (shortly after booting) still quite busy with delayed loading of other base-stuff like services etc. -
    in addition to loading the quite large Chromium-Runtime, ... so the default of 5sec may be a bit too short -
    (I can imagine, that older magnetic disks might play a role, because I see no larger delay here on my test-OSes on SSDs).

    You could:
    - either try to increase that TimeOut-Param (to maybe 10sec or so)
    - or set it to Zero, to tell the methods to wait for their matching EventHandlers
    .. (WV_InitComplete or WV_NavigationCompleted respectively, to proceed with your own, now async Inits from within those Handlers)
    Yes, after changing SecondsToWaitForInitComplete from 5 to 10, the problem was solved. Thank you very much.

    Quote Originally Posted by Schmidt View Post
    You still planning on using the IE further???
    I plan to gradually replace IE with WebView2 in the next period of time, but it will take some time. During this period, IE and WebView2 will exist in my system at the same time.

    Quote Originally Posted by Schmidt View Post
    Well, there's an IHTMLPainter interface one can cast to (IIRC, from an IHTMLWindow2), which offers a Draw-method.
    There's also PrintPreview-interfaces which allow capturing of one (or more) pages.
    Ok. I will try this method.

    Quote Originally Posted by Schmidt View Post
    And of course you could try to work via API-calls directly on the hWnd of that Control, to copy its current Render-Output.
    Yes, I know this way. I can use SendMessage(...WM_PRINT...) to capture IE Preview.

    In addition, my current project is almost finished. In a few months, I will start to develop a scripting language and IDE similar to VB6 (of course, the development time is also calculated in years). If you could provide some good seeds (prototypes or suggestions), maybe I can develop a decent scripting language and IDE, and this IDE may be applied to your VB6-compatible compiler.

    (From dm)
    Last edited by SearchingDataOnly; Nov 8th, 2020 at 05:47 AM.

  16. #16
    Lively Member
    Join Date
    Aug 2016
    Posts
    96

    Re: VB6 WebView2-Binding (Edge-Chromium)

    This came as a surprise.

    Olaf, we can't thank you enough for your contribution.

    I haven't tested it yet but I am already thrilled.

    This is something I have been searching for for a long time.

  17. #17
    New Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Hello Olaf
    Fantastic job! I dreamed about it for many months and you did it, fabulous!


    Is there a way to force the localization of the cWebView2 component? On my computer, the sub menus are still in English despite an installation on a French Windows 10!


    The only way I have found to solve this problem is to destroy the EN-US.pak file in the Locales folder of the EdgeWebView installation and rename fr.pak to EN-US.pak! It works but it is not very clean!


    Do you have an idea ?


    Many Thanks

  18. #18

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,007

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by saturnian View Post
    Is there a way to force the localization of the cWebView2 component?
    On my computer, the sub menus are still in English despite an installation on a French Windows 10!
    Ah, yes... sorry.

    Forgot to reset my internal Lang-Handling "to normal" (it was still hardwired to "en" for my own tests) ...
    (fixed that just now, so the next RC6-version will start with the default-language of the current system again, regarding Popup-Menus and other localizations).

    But (regarding a workaround, applied to the version you currently have...) -
    there's always the last (optional) Param in the BindTo-method, which can "influence everything" (config-wise).

    BackGround:
    This last param (additionalBrowserArguments) can take up (and later represents) the commandline-args,
    which are passed to the Chromium-Process which gets started under the covers for every WebView.

    So, a simple change of the BindTo-line (passing an appropriate cmd-string):
    If WV.BindTo(picWV.hWnd, , , , "--lang=fr") = 0 Then ...
    or (for the chinese readers here, because it might not be obvious)
    If WV.BindTo(picWV.hWnd, , , , "--lang=zh-cn") = 0 Then ...
    ...should do it for you (until the next RC6-version, where - as said - the current locale will determine the default again).

    As for the list of available commandline-switches - it is quite a long one (but described for example here):
    https://peter.sh/experiments/chromiu...line-switches/

    HTH

    Olaf

  19. #19
    New Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    thank you so much, Olaf

  20. #20
    New Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Another question, Olaf!
    Is there a way to intercept the URL when opening a new window after clicking on the "Open in new tab" submenu?
    This would allow programming the display of the new page in a new cWebView2

  21. #21
    New Member
    Join Date
    Nov 2020
    Posts
    1

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Thanks Olaf, this is really superb work. My VB6 app can finally be HTML5 compatible.

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,007

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by saturnian View Post
    Another question, Olaf!
    Is there a way to intercept the URL when opening a new window after clicking on the "Open in new tab" submenu?
    This would allow programming the display of the new page in a new cWebView2
    Right, the old Param-amount in that Event was only allowing "suppression of the built-in NewWindow-Handling"
    (though did not give much info about "what to construct, in case one wants to create his own thing").

    So, this Event was enhanced in the new version 6.0.2, which I've just uploaded to the usual place...

    A Test-Handler for the original demo (showing the new incoming Event-Args) is the following one:
    Code:
    Private Sub WV_NewWindowRequested(ByVal IsUserInitiated As Long, IsHandled As Long, ByVal URI As String, NewWindowFeatures As RC6.cCollection)
      Debug.Print "URI: "; URI
      
      Dim i As Long 'Print out, what's sitting behind the NewWindowFeatures JSON-Collection
      For i = 0 To NewWindowFeatures.Count - 1
        Debug.Print NewWindowFeatures.KeyByIndex(i), NewWindowFeatures.ItemByIndex(i)
      Next
      
      IsHandled = 1 'prevent the WebView from "doing its own thing" about the new window
    End Sub
    HTH

    Olaf

  23. #23
    New Member saturnian's Avatar
    Join Date
    Dec 2017
    Location
    France
    Posts
    13

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Thanks, Olaf! It works perfectly

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