-
Re: VB6 WebView2-Binding (Edge-Chromium)
Found two problems, help to have a look.
webview2 loading objects is slow, can you do an asynchronous version, as long as you set the URL, the background will automatically create, create an event after completion. And then go to the website
HTML Code:
Set Webview1 = New_c.WebView2
Webview1.BindTo(UserControl.hWnd)
Code:
Set Webview1 = New_c.WebView2
webview1.NewWebViewAnsy(picture1.hwnd,URL AS STRING)
SUB NewWebViewAnsy(ParentHwnd as long,Url1) IN CreateThread or ansy
Webview1.BindTo(UserControl.hWnd)
raiseevent WebviewLoadOK()
Webview1.Navigate URL1
end sub
Url without http added will Navigate and crash Webview1.Navigate "baidu.com
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
webview2 loading objects is slow, can you do an asynchronous version
Async mode is already built-in, via the SecondsToWaitForCompletion-parameter.
(in the Constructor/Bind and also in the Navigate-Methods).
There is also an Event, which signalizes a successful binding (the InitComplete-Event).
Here is an example, how to work asynchronously (with constructor-binding and navigation):
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Set WV = New_c.WebView2(hWnd, 0) '<- setting the "TimeToWait" to 0, will do this bind-call asynchronously
Debug.Print "now exiting Form_Load (relying on WV_InitComplete)"
End Sub
Private Sub Form_Resize()
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
Private Sub WV_InitComplete()
Debug.Print "InitComplete"
WV.Navigate "https://google.com", 0 '<- same 0-TimeToWait for an async Nav-method-call
End Sub
Quote:
Originally Posted by
xiaoyao
Url without http added will Navigate and crash Webview1.Navigate "baidu.com
It does not "crash" - instead what it does, is raising an Error 5 (wrong argument).
And a wrong argument means (in this case), that the URL-Param requires a "protocol-prefix"
(like "http://" or "https://")
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
WV_InitComplete()
This is a good way.
If at the beginning of the binding object, directly set the URL to complete the asynchronous do not have to pay attention to, so better.
The radio parameters are done automatically as if it were a multi-threaded delegate, and then notify me.I mainly use it to load 10 webview controls at the same time in one second, and each control opens the URL according to the array, so I just need to send out the task and he will finish it in the background.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
It would be better if 64-bit rc6.dll can be developed. Only some functions can be realized. Can you support the function of creating websocket server, so that I can directly open Google browser and use the plug-in ws://127.0.0.1 Connect to the RC6 point dll. I don't know if webview2 object supports edge and Google plug-in. If not, I will load a js URL or local script. Pytho operates Google and edge driver, and they provide more functions and are more convenient. So if you use this, there is still a lot of code to be implemented in js.
rc6.DLL,Is it possible to remove sqlite3.dll if you are not using a database?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
saturnian
To test, I wrote a multi-tab browser, which begins to work well.
François
Have you ever developed a custom control to wrap webview2?
So you can use it like webbrowser. I have encountered many puzzling problems, such as the size has not changed and I can't display the web page.Is there any way to operate in an Excel vba,vbs file? It will automatically open an edge browser window or a simple form display page. You don't need to bind to a handle. And if you click on a web page, it will pop up a new tab or page. Can you also read its contents with code?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
If I have added code using "AddScriptToExecuteOnDocumentCreated", how would I clear that again?
... .. .
Dear Olaf,
I also need a way to remove the script added via "AddScriptToExecuteOnDocumentCreated". Thanks a lot for your answers in connection with this but I did not find them helping me in my case. So, I tried my very best (for the past 3 days or so, whenever I could get time) to find a way out (some sort of hack at least) to tackle this issue but I am unable to, so far. So, I am stuck.
Today, though, when browsing the net in connection with the above issue, I came across this page - https://learn.microsoft.com/en-gb/mi...ocumentcreated ( RemoveScriptToExecuteOnDocumentCreated ). Reading what this function does, it seems like this is what I require. But then, you are the expert. May be the aforesaid function does NOT exactly do what I require. If so, kindly bear with me and kindly let me know the same. On the other hand, if at all the aforesaid function indeed does what I require, then I request you to kindly include it in RC6 WV, if at all possible. It will simplify my tasks like anything. I would be much grateful to you for the same.
I take this opportunity to once again thank you in tons for all your contributions and support.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
saturnian
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)
I don't know how it goes now. Where can I download the preview version?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
- then instantiate New_c regfree within your App (via a declared DirectCOM.dll GetInstance or GetInstanceEx-call)
- and then initiate the Binding by a Class-instance, derived via New_c.WebView
1,rc6.dll
2,sqlite3.dll
3,webview2load.dll
4,DirectCOM.dll
5,abc.exe >> bind to vb6 picture1.hwnd
This requires so many files that I don't mind the file size.
DirectCOM.dll,In fact, the output API can be implemented directly in rc6.dll. The ActiveX DLL object can also output the stdcall API,
If SQLite 3.dll can specify the path, it would be better to modify the file name. Register rc6.dll without sqlite3.dll, I just load it when I need it, that's fine.
An interface can be added,Display a web page window directly without writing any code.
like this in vb6
Code:
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://www.baidu.com"
ie.visible=true
quick open url on excel vba,or vbscript:
Code:
Public Declare Function DirectCom_Create Lib "rc7.dll" Alias "GETINSTANCE" (FName As String, className As String) As Object
Public Declare Function NewWindow Lib "rc7.dll" (byval url As String) As Object
dim web2 as object
set web2=DirectCom_Create("rc7.dll","cwebview2")
web2.NewWindow("http://www.baidu.com")
web2.visible=true
or
Code:
dim web2 as object
set web2=NewWindow("http://www.baidu.com")
web2.visible=true
like new version of rc7.dll
rc7.vpb add text to end:
[VBCompiler]
LinkSwitches=-EXPORT:NewWindow -Export:GetInstance -Export:AutoSetup -Export:CheckSetup -Export:Add -EXPORT:ShowForm1
Code:
Dim Web1 As CwebView2
Public Function NewWindow(Url As String) As CwebView2
Set Web1 = New CwebView2
Web1.Navigate Url
Set NewWindow = Web1
End Function
Public Function GetInstance(FName As String, className As String) As Object
'**** code
End Function
Public Function AutoSetup() As Boolean
'download Url = "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
'download Url to Edge_Webview2RunTime.exe
'ShellWait(App.Path & "\Edge_Webview2RunTime.exe /silent /install"
End Function
Public Function CheckSetup() As Boolean
'
End Function
-
Re: VB6 WebView2-Binding (Edge-Chromium)
We are trying to create an adblocker.
Here is what my collegue would like to ask:
Is it possible to use AddWebResourceRequestedFilter method?
I can't write to form, it says I am not authorized.
Can you give an example about using AddWebResourceRequestedFilter method, if possible?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Want to turn rc6.dll Cwebview2 objects into a portable browser, without any ads and other menus
You can call the
Code:
rundll32.exe rc6.dll,WebViewOpenurl,https://www.163.com
with the vbs
Methods like this. This displays the form interface in the dll and loads a web page
Features that can be achieved, automatically maximize the form, or hide the top navigation bar of the form. Pure web pages can also be mobile.
Set the form size, remember the form size, the next time open or the same location.
Main purpose, quickly open some web pages, or form the top way to load web page applications. Like a mobile web-page calculator.
Or are shown as the front end of the PYTHON. PYTHON The back-end uses the websocket service to receive the data, enter the web page order, and deposit PY in the database.
You can directly use VBS and EXCEL VBA to load web pages to obtain objects, control webview2 objects, send JS commands, and collect web page content.
Code:
SET WEB=createobject("rc6.cwebview2")
web.WindowOpen("https://www.baidu.com")
web.visiable=true
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
Want to turn rc6.dll Cwebview2 objects into a portable browser...
Why use "rundll.exe", when you can compile a small executable with VB6 - and make it load the New_c in a regfree manner -
via the already outlined methods, as e.g. here: https://www.vbforums.com/showthread....ectCOM-amp-RC6
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
The problem is that we are missing the WebResourceRequested event.
Event WebResourceResponseReceived(ReqURI As String, ReqMethod As String, RespStatus As Long, RespReasonPhrase As String, RespHeaders As cCollection) is already too late, I think.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
The problem is that we are missing the WebResourceRequested event.
Event WebResourceResponseReceived(...) ...is already too late, I think.
WebResourceResponseReceived is triggered from e.g.:
WV.NavigateWithWebResourceRequest
You're right in, that the proper Event which corresponds with: WV.AddWebResourceRequestedFilter -
is the WebResourceRequested which is now included (in just uploaded RC6-version 6.0.13)...
I've also added the new NavigationStarting-Event (which is another one, which allows cancelling requests - on "whole documents").
Here's how to use the new WebResourceRequested-Event (which will only be triggered, once a Filter was added):
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Visible = True
Set WV = New_c.WebView2(hWnd)
WV.AddWebResourceRequestedFilter "*googlelogo*" 'define an URI-filter with wildcards
WV.Navigate "https://google.com"
End Sub
Private Sub Form_Resize()
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
'requires RC6 >= 6.0.13
Private Sub WV_WebResourceRequested(ByVal URI As String, ByVal FilterType As RC6.eWebView2ResourceFilter, Permit As RC6.eWebView2PermissionState)
Debug.Print FilterType, FilterType = Filter_IMAGE, URI
Permit = PERMISSION_STATE_DENY
End Sub
So, the above will report (in the Event), all "sub-requests" which in their URI contain the "wildcarded" string-snippet
(in case of the example, the filter-string was "*googlelogo*").
Within the Event you can then take a closer look at the URI which contained that filter-snippet -
and then decide (depending on resourcetype and "whole URI-string", whether you want to "403 cancel" it, or not).
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Dear Olaf,
In post no. 342, you have written as follows:
// The chromium-engine (which MS-Edge-WebView2 is using under the covers) -
is already working "multi-process-based" underneath - a short view into the Taskmanager would show you that... //
Thanks for the above info and I could indeed see the MS-Edge-WebView2 process(es) in TaskManager. I have a few questions related to it. As far I searched through this thread, I could not find these questions asked. Hence, asking.
----------
Suppose I have an app (A.exe) showing a web page in its 1st screen (say 'X') using WV.
When I open A.exe, some "Microsoft Edge WebView2" processes are shown running in the Processes list. If I close A at once, all the aforesaid "Microsoft Edge WebView2" processes disappear from the Processes list.
Instead of the above scenario, after opening 'A', if I click a link in 'X' (which link has target="_blank" and it is for a web page 'Y' ) so that 'Y' web page opens in a new window (say 'N'). Now, when I close 'A', 'N' window showing 'Y' web page still remains on the screen. Upon checking the Processes list, there remains in it a primary "Microsoft Edge WebView2" process with some child processes inside it. Is this the normal behaviour? If so, what exactly is happening? I presume 'N' showing 'Y' is running now as a separate process in a separate "Microsoft Edge WebView2" runtime process (say 'M'). Am I right?
Well, in any case, based on the abovementioned still-running 'N' window, I have the following sub-questions:
1. What is the best way to automatically close such 'N' windows (one or many) when I close my main application 'A'? Is there a possibility to have a property in WV by which I say that whenever I close 'A', all 'N' windows opened by 'A' shall be closed automatically? Or, is there already present a simple method in WV by which during Unload of 'A', I can close all 'N's easily?
2. What if I don't close such 'N' windows and open my application 'A' again? I presume there will be no relationship between the already-opened 'N' windows and 'A'. Am I right in this presumption? If so, if I allow users to open many such 'N' windows in many different sessions of 'A', then each one of those 'N' windows will be running under the abovementioned 'M' process (of "Microsoft Edge WebView2") and user can opt to close each of those 'N' windows himself, whenever he wishes to, later. Right? In other words, there will not be any problems at all in 'A' being opened/closed several times when many already opened 'N' windows are existing. Right? Kindly let me know.
----------
I take this opportunity to thank you once again, heartily, from the bottom of my heart, for all that you do to help us out.
Kind regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I INSTALL this,MS-DownloadLink
https://go.microsoft.com/fwlink/p/?LinkId=2124703
Error in FindFirstFile: ErrNum: 3, The system cannot find the specified path
OK = Web1.BindTo(Web1pic.hWnd) <> 0
==========
I specify the old version and it works:
OK = Web1.BindTo(Web1pic.hWnd, , App.Path & "\SystemFile\web110.0.1587.63.x86")
Quote:
Originally Posted by
Schmidt
There seems to be a problem with the installation of the WebView-Runtime...
The BindTo-call is looking for the WebView-Runtime-BaseFolder via the following Path-Expression:
(for your Immediate-Window):
?New_c.FSO.GetSpecialFolder(CSIDL_PROGRAM_FILESX86) & "\Microsoft\EdgeWebView\Application"
Olaf
i search in hrer:C:\Users\***\AppData\Local\Microsoft\EdgeWebView
not C:\Program Files (x86)\
Code:
HKEY_CURRENT_USER\Software\Microsoft\EdgeUpdate
path=C:\Users\xiaoyao\AppData\Local\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe
how to get newwindow by webview2 control?
and how to do that new webvie2 like runjs,openurl(**)
if have 3 new window ,how to do?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
last time ,i found someone say check reg path from :HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}\
cant find location in this regpath
It is possible that the Webview sdk is not installed with administrator permission. Therefore, there is no data in HKEY_LOCAL_MACHINE. Only HKEY_CURRENT_USER is saved
HKEY_CURRENT_USER\Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
edgesdk=""
CreateCoreWebView2EnvironmentWithOptions(StrPtr(edgesdk), StrPtr(userdata)
A direct API call with an empty path will automatically detect where the system is installed.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
As for detection, whether a given target-system already contains this runtime,
you can simply check the output of the GetMostRecentInstallPath-method:
This function failed to get the WEBVIEW SDK installation path
Set Web1 = New_c.WebView2
Web1.GetMostRecentInstallPath
RC6.DLL 2023-5-29 version still has this problem
Code:
Dim OK As Boolean
Set Web1 = New_c.WebView2
Dim WebViewSDK As String
WebViewSDK = GetEdgeWebViewPath
If WebViewSDK <> "" Then
OK = Web1.BindTo(Me.hWnd, , WebViewSDK) <> 0
End If
Function GetEdgeWebViewPath() As String
On Error Resume Next
Dim WshShell As Object, WebView2_Version As String
Dim RegPath As String, location As String
Set WshShell = CreateObject("Wscript.Shell")
RegPath = "HKEY_CURRENT_USER\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}\"
location = WshShell.RegRead(RegPath & "location")
If location = "" Then
RegPath = Replace(RegPath, "\WOW6432Node", "")
location = WshShell.RegRead(RegPath & "location")
End If
If location <> "" Then GetEdgeWebViewPath = location & "\" & WshShell.RegRead(RegPath & "PV")
End Function
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
In my understanding, Selenium was written as a generic Test-Tool which can "work against multiple Browser-engines".
The WebView2 is just an encapsulation of a single Browser-engine (chromium) -
minus the additional "generic Automation- and Test-interfaces".
So, if you currently use Selenium for your own testing-purposes with success,
why change it to something "less capable" and "less generic".
Just my $0.02...
Olaf
I used to do this with IE, and there was a program that would automatically start IE and add some command line arguments.
So I used VB6 to write a program, replace IE path, and then use the WEBBROWSER to load the web page, the command line needs to open the URL.
chrome.exe works the same way. chromedriver.exe will send a WebSocket-related URL, and then through developer tools and other principles, you can use the driver proxy to open the URL, click the button.
I went over everyone's responses and questions several times today. And tested it.
If everyone can solve the problem, then do a test code is convenient. Then indicate which forum the question is placed in.
I heard that Google Chromium kernel source code related projects have a total of about 20G, the final compilation of DLL and related files may only be several hundred M.
Just because of the amount of documentation, the development tools, are important assets, learning paths.
I've always been studying very seriously, but sometimes the focus is different.
FOR EXAMPLE, I WANT RC6 .DLL TO RUN INDEPENDENTLY, SO THAT A WEB PAGE CAN BE DISPLAYED BY CALLING A STANDARD DLL API AND A WEBVIEW OBJECT CAN BE OBTAINED.
It's like VB6 calling WebView2Loader.dll, which is a VC++ COM object, but also outputs the 4 API exports of the standard DLL.
With this, there is a complete source code and webview2.tlb, which can be added in VB6.
So if RC6 .DLL can expose webview objects, then many users can extend some of the functionality that RC6 lacks.
If you only need an API to directly display a form loading web page by yourself, you will not cause multithreaded calls to some callbacks in the VB.NET and crash.
Of course, some features are added that are really convenient, but they also take a lot of time and technical difficulty to do.
After 25 years, Twinbasic implemented almost all vba.**, vb6.**, app.* objects and methods. Implements 64-bit compilation to generate EXE.
The next thing VB6 needs is a relatively large project, such as RC6 .DLL some extended functions or test methods. IF YOU CAN DO A GITHUB PROJECT.
You can directly upload, modify, and the main administrator is responsible for synthesis.
If there is also a package manager NuGet. PIP.EXE ,NPM
Everyone can directly check and install cZipArchive.cls, iSubclass_Mini.cls, stdPicEx.cls
VB6 is in decline now, maybe our generation of old programmers can last for 10-30 years.
It would be convenient to have a powerful online source management and questioning tool.
In any case, many of my requests are still unreasonable, and very few people are used. I'm really sorry
In fact, I also posted a lot of code bases on the forum, maybe some people feel that the code is too simple, and they are not qualified to be called "code bank",
But there are parts that I also spent a lot of time summarizing and testing.
We are all amateurs, selflessly contributing everyone's experience and technology to the convenience of others. Nor can you ask others to do too much.
After all, only commercial companies like TwinBasic can achieve a large number of technological updates, but they cannot achieve the correct and reasonable requirements to meet and complete the development.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
How to drag a web page and move the entire form?
I want to make a pure web page without a form border and put it inside the WEBVIEW
Then move the web page and the whole interface moves with it, either by typing shortcuts or virtual minimize and maximize buttons in the web page.
Do not know how to achieve
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Dear Olaf,
A possible issue in the latest release (29th May 2023) of RC6.dll
I don't know whether the issue is because of a mistake at my end OR the following is indeed an issue in the latest release of RC6.dll
The issue is:
--
When I use WV.Navigate to navigate to some external^^ site (not all, but some), the WV.DocumentTitle and WV.DocumentURL are not getting set.
Example sites:
https://sureshramaswamy.org
https://dandapani.org
(^^) as opposed to local html files in my own system.
--
1. When WV.DocumentTitle and WV.DocumentURL are not set for a particular site, if they are accessed (say, made to be printed via the statement Debug.Print "a-" & WV.DocumentTitle & "-a", "b-" & WV.DocumentURL & "-b", it takes quite a few seconds for the blank strings to be printed.
2. If I navigate to 'https://google.com', the "WV_DocumentComplete" event itself does not occur (apart from the title and url not getting set). Strangely, this is the case with the previous RC6.dll also. No issues with URLs like "google.de", "google.in", etc.
3. I found one or two other anomalies also while visiting some external sites (with the latest RC6.dll) but I felt they will get resolved automatically if the above issues are taken care itself. So, not mentioning about them, as of now.
As of now, in my app (checked with your own WebView2 Demo project also), I have started using the previous RC6.dll itself and absolutely no issues with WV.DocumentTitle and WV.DocumentURL except for the solitary site "https://google.com"
In case, the issues I have reported above are because of some mistake I am committing at my end only, then kindly let me know what to do to rectify the same.
I take this opportunity to thank you in tons, once again, Olaf, for your contributions to the world society.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
A possible issue in the latest release (29th May 2023) of RC6.dll
.
As of now, in my app (checked with your own WebView2 Demo project also), I have started using the previous RC6.dll itself and absolutely no issues with WV.DocumentTitle and WV.DocumentURL except for the solitary site "https://google.com"
In case, the issues I have reported above are because of some mistake...
No, can reproduce this here with your site-links.
Background:
In an attempt to circumvent the "suppression of added COM-Objects" (which "google.com" achieves, when it is loading) -
I've changed the handling of the COM-Host-storage in 6.0.13 ...
though without success as it seems...
Have now restored the former vb_Host-behaviour in new version 6.0.14 (to what it was in 6.0.12).
It's uploaded now (have not updated the page-labels to 6.0.14 though).
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
... .. . In an attempt to circumvent the "suppression of added COM-Objects" (which "google.com" achieves, when it is loading) -
I've changed the handling of the COM-Host-storage in 6.0.13 ...
though without success as it seems...
Have now restored the former vb_Host-behaviour in new version 6.0.14 (to what it was in 6.0.12). ... .. .
Olaf
Thanks a ton, Olaf, for your mighty quick response. Yes, all back to normal now.
Navigating to "google.com" alone does not populate the DocumentURL and DocumentTitle. But, from your reply I infer that it will be so for "google.com" alone. Am I right?
Note:
Using the latest RC6 (6.0.14), WV.Navigate "https://google.com" does trigger the 'WV_DocumentComplete' event but WV.DocumentURL and WV.DocumentTitle do not get populated. They are blank/empty.
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
Using the latest RC6 (6.0.14), WV.Navigate "https://google.com" does trigger the 'WV_DocumentComplete' event but WV.DocumentURL and WV.DocumentTitle do not get populated. They are blank/empty.
Yes, whilst "google.de" works, "google.in" works, etc. -
the scripts Google loads (and runs), when loading from "google.com",
are somehow crippling the COM-Object-Callback-mechanism of MS.
And in turn, everything my wrapper offers communication-wise (.jsRun, .jsProp, etc.) is also crippled.
(though only, when google.com was the navigation-target).
As said, have started to find a way to circumvent this in 6.0.13,
but as you found out - this affected other functionality with "formerly normal behaving URLs" (hence the back-paddling in 6.0.14).
Think I'd like to wait a few months at this point,... perhaps MS comes up with a fix for that themselves -
(or Google changes their offending script) ...if not, I'll restart my own attempts after that again...
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
i have a full test:WebView2Demo.vbp,
i install MicrosoftEdgeWebview2Setup.exe for only user1,not for all user.
change to windows user2(local user):
RC6_ 2022-0731
---------------------------
Runtime error '430':
Class does not support automation or expected interfaces
---------------------------
RC6_ 2023-0529
---------------------------
Err: 53, Error in FindFirstFile: ErrNum: 3, the system cannot find the specified path.
Couldn't initialize WebView Binding
this will check HKEY_CURRENT_USER ,HKEY_LOCAL_MACHINE,WOW6432Node,x64
Code:
Function GetEdgeWebViewPath() As String
On Error Resume Next
Dim WshShell As Object, WebView2_Version As String
Dim RegPath As String, location As String
Set WshShell = CreateObject("Wscript.Shell") 'HKEY_CURRENT_USER , HKEY_LOCAL_MACHINE
RegPath = "HKEY_CURRENT_USER\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}\"
location = WshShell.RegRead(RegPath & "location")
If location = "" Then
RegPath = Replace(RegPath, "\WOW6432Node", "")
location = WshShell.RegRead(RegPath & "location")
If location = "" Then
RegPath = "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}\"
location = WshShell.RegRead(RegPath & "location")
If location = "" Then
RegPath = Replace(RegPath, "\WOW6432Node", "")
location = WshShell.RegRead(RegPath & "location")
End If
End If
End If
If location <> "" Then GetEdgeWebViewPath = location & "\" & WshShell.RegRead(RegPath & "PV")
End Function
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
i have a full test:WebView2Demo.vbp,
i install MicrosoftEdgeWebview2Setup.exe for only user1, not for all user.
change to windows user2(local user):
... no WebView2-instancing possible via RC6...
What's your question exactly?
And why do you expect user2 to be able to create a WebView2-instance,
when you did not ensure an installation of the WebView2-runtime for that specific user2?
(or alternatively for all users of the machine)
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Confirm that the EDGE Evergreen SDK was installed with non-administrator privileges last time, and only the installation data is found in the registry HKEY_CURRENT_USER (64-bit subkey).
The path is: C:\Users\xiaoyao\AppData\Local\Microsoft\EdgeWebView\Application\114.0.1823.37
EDGE information cannot be found in registry subkeys such as HKEY_LOCAL_MACHINE and 32-bit
I switched to another Windows local administrator account and need to obtain directory permissions to access the previous user's directory: C:\Users\xiaoyao\AppData
Then VB6 called WebView2Loader.dll loaded webview2 successfully, using fixed versions (old version) 109.0.1518.78.x86 and 110.0.1587.63.x86, tested that 3 versions of EdgeWebView SDK displayed web pages correctly.
However, RC6 .dll specifying these 3 SDK directories to load webview2 failed.
couldn't initialize WebView-Binding
Install the Microsoft EdgeWebview2Setup .exe in administrator mode
The path to the automatic installation is: C:\Program Files (x86)\Microsoft\EdgeWebView\Application
---------------------------
The installation directory of EdgeWebView can also be found in the registry where the installer is uninstalled
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView
InstallLocation=C:\Users\xiaoyao\AppData\Local\Microsoft\EdgeWebView\Application
Version=114.0.1823.37
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView
InstallLocation=C:\Program Files (x86)\Microsoft\EdgeWebView\Application
Version=114.0.1823.41
-
Re: VB6 WebView2-Binding (Edge-Chromium)
The default double-click installation is non-administrator permissions, the path is: C:\Users\%user%\AppData\Local\Microsoft\EdgeWebView\Application\
Right-click to install with administrator privileges, the path is: C:\Program Files (x86)\Microsoft\EdgeWebView\Application
So you cannot directly specify the directory C:\Program Files (x86)\.
You can try it this way:
edgesdk="" or 2 other fixed (legacy) runtimes are fine
If CreateCoreWebView2EnvironmentWithOptions(StrPtr(edgesdk), StrPtr(userdata), 0&
After the user loads successfully, you can write down the current SDK installation directory. If the software user installs the software with non-administrator privileges and switches to another user to log in,
Use the code to crack the permissions, or let the user click on the authorization to access the directory, so that there is no need to install it again.
-----------------------------------
If each user needs to install the SDK separately, it will occupy 600-800MB of hard disk space, and 2 users is 1.5GB of space
Because we can't guarantee that the user will definitely install with administrator privileges, or it may just be a non-administrator account (the company implements permission control for users)
If his account has administrator privileges, but does not have the right mouse button to click administrator privileges, the installation will not take effect.
You can write your own installation script "runas" to force the installation of the runtime
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
Use the code to crack the permissions, or let the user click on the authorization to access the directory...
I'd suggest to other readers here, to not "crack any permissions"...
The only things that needs to be done is, to run the WebView2-evergreen-installer properly "as Admin".
(after downloading it from the MS-WebSite).
Quote:
Originally Posted by
xiaoyao
If each user needs to install the SDK separately, it will occupy 600-800MB of hard disk space...
And that large size is the reason, why it makes so much sense, to choose the "for all Users" option -
on the given machine (once the installer was started "in Admin-mode").
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Loading two WebVIEWs is slow, why?
Code:
Web1 InitComplete UsedTime:111.3823ms
Web2 InitComplete UsedTime:8124.4131ms
WEB1 NavigationCompleted Used:16458.6068ms
WEB2 NavigationCompleted Used:16462.0363ms
Code:
Option Explicit
Dim WithEvents Webview1 As RC6.cWebView2
Dim WithEvents Webview2 As RC6.cWebView2
Dim AA(10) As Currency, BB(10) As Currency, U1 As Currency, U2 As Currency
Dim Web1 As RC6.cWebView2
Private Sub Webview1_InitComplete()
QueryPerformanceCounter AA(2)
U1 = (AA(2) - AA(1)) / MsCount
Debug.Print "Web1 InitComplete UsedTime:" & U1 & "ms"
'Webview1.SyncSizeToHostWindow
Webview1.Navigate "https://www.baidu.com?id=1"
End Sub
Private Sub Webview2_InitComplete()
QueryPerformanceCounter BB(2)
U2 = (BB(2) - BB(1)) / MsCount
Debug.Print "Web2 InitComplete UsedTime:" & U2 & "ms"
'Webview2.SyncSizeToHostWindow
Webview2.Navigate "https://www.baidu.com?id=2"
End Sub
Private Sub Webview1_NavigationCompleted(ByVal IsSuccess As Boolean, ByVal WebErrorStatus As Long)
QueryPerformanceCounter AA(3)
U1 = (AA(3) - AA(1)) / MsCount
Debug.Print "WEB1 NavigationCompleted Used:" & U1 & "ms"
End Sub
Private Sub Webview2_NavigationCompleted(ByVal IsSuccess As Boolean, ByVal WebErrorStatus As Long)
QueryPerformanceCounter BB(3)
U2 = (BB(3) - BB(1)) / MsCount
Debug.Print "WEB2 NavigationCompleted Used:" & U2 & "ms"
End Sub
Private Sub Form_Activate()
If Me.Tag = "" Then
Me.Tag = "a"
QueryPerformanceCounter AA(1)
QueryPerformanceCounter BB(1)
Webview1.BindTo Picture1.hWnd, 0&, WebviewSDKPath, "Z:\TEMP"
Webview2.BindTo Picture2.hWnd, 0&, WebviewSDKPath, "z:\temp2"
' Webview1.BindTo Picture1.hWnd, , WebviewSDKPath, "Z:\TEMP"
' Webview2.BindTo Picture2.hWnd, , WebviewSDKPath, "Z:\TEMP"
'Webview1.Navigate "https://www.baidu.com"
'Webview2.Navigate "https://www.baidu.com?id=2"
End If
End Sub
Private Sub Form_Load()
Set Webview1 = New_c.Webview2 'New cWebView2
Set Webview2 = New_c.Webview2 'New cWebView2
END SUB
IN my vb6 api webview2
two webview use same userdata path:
Code:
2023/6/8 16:39:04 class1:web1
2023/6/8 16:39:04 class1:Web2
2023/6/8 16:39:04 class2:web1
2023/6/8 16:39:04>web1-InitComplete,116.7922ms
2023/6/8 16:39:04 class2:Web2
2023/6/8 16:39:04>Web2-InitComplete, 147.2914 ms
2023/6/8 16:39:04>web1-Completed usedtime 422.0084 ms
2023/6/8 16:39:04>Web2-Completed usedtime 465.4944ms
two webview use 2 userdata path:
Code:
----------vb6 api load webview2:
2023/6/8 18:09:04 class1:web1
2023/6/8 18:09:04 class1:Web2
2023/6/8 18:09:05 class2:web1
2023/6/8 18:09:05>web1-InitComplete, 437.4444 ms
2023/6/8 18:09:05>web1-Navigate 0.0443 ms
2023/6/8 18:09:05 class2:Web2
2023/6/8 18:09:05>Web2-InitComplete, 503.0666ms
2023/6/8 18:09:05>Web2-Navigate used 0.0215 ms
2023/6/8 18:09:05>web1-Completed, 827.0572ms
2023/6/8 18:09:05>Web2-Completed, 891.6135 ms
2023/6/8 18:09:14 RC6-Webview2 Test Start
Web1 InitComplete UsedTime:101.1542ms
Web1 Navigate UsedTime:3.1012ms
Web2 InitComplete UsedTime:454.1865ms
Web2 Navigate UsedTime:1.5263ms
WEB1 NavigationCompleted Used:537.3491ms
WEB2 NavigationCompleted Used:888.683ms
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Webview1.Navigate "https://www.baidu.com?id=2",0
Webview2.Navigate "https://www.baidu.com?id=2",0
There is actually no need to wait here, if you want to wait, add a new function web.wait interface
Web1 InitComplete UsedTime:45.2891ms
Web2 InitComplete UsedTime:503.8269ms
WEB1 NavigationCompleted Used:586.6115ms
WEB2 NavigationCompleted Used:979.8215ms
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
Loading two WebVIEWs is slow, why?
Because you never read (or understand), what was already explained to you in #362.
The default-settings of the RC6-WebView2-wrapper will ensure synchronous calls... (to make it a bit more beginner-friendly).
To change that to async-mode, one has to pass 0-WaitTimeouts into the second parameters of the Bind- and Navigate-methods.
Code:
Option Explicit
Private WithEvents WV1 As cWebView2, WithEvents WV2 As cWebView2
Private WithEvents PB1 As PictureBox, WithEvents PB2 As PictureBox
Private Sub Form_Load()
Set PB1 = Controls.Add("VB.PictureBox", "PB1"): PB1.Visible = True
Set PB2 = Controls.Add("VB.PictureBox", "PB2"): PB2.Visible = True
New_c.Timing True 'start high-res-timing
Set WV1 = New_c.WebView2(PB1.hWnd, 0)
Set WV2 = New_c.WebView2(PB2.hWnd, 0)
End Sub
Private Sub WV1_InitComplete()
Debug.Print "WV1_InitComplete", New_c.Timing
WV1.Navigate "https://sqlite.org/index.html", 0
End Sub
Private Sub WV2_InitComplete()
Debug.Print "WV2_InitComplete", New_c.Timing
WV2.Navigate "https://sqlite.org/index.html", 0
End Sub
Private Sub WV1_NavigationCompleted(ByVal IsSuccess As Boolean, ByVal WebErrorStatus As Long)
Debug.Print "WV1_NavigationCompleted", New_c.Timing
End Sub
Private Sub WV2_NavigationCompleted(ByVal IsSuccess As Boolean, ByVal WebErrorStatus As Long)
Debug.Print "WV2_NavigationCompleted", New_c.Timing
End Sub
Private Sub Form_Resize()
If Not PB1 Is Nothing Then PB1.Move 0, 0, ScaleWidth, ScaleHeight \ 2
If Not PB2 Is Nothing Then PB2.Move 0, ScaleHeight \ 2, ScaleWidth, ScaleHeight \ 2
If Not WV1 Is Nothing Then WV1.SyncSizeToHostWindow
If Not WV2 Is Nothing Then WV2.SyncSizeToHostWindow
End Sub
Timing-Results for the now async behaving 2 WV-instances (at the cost of using more Event-Handlers):
Code:
WV1_InitComplete 161.83msec
WV2_InitComplete 177.61msec
WV1_NavigationCompleted 270.31msec
WV2_NavigationCompleted 285.15msec
For the record:
Performance-comparisons between basic-methods of the WebView2 are pointless (across wrapper-implementations) -
in the end, it is the same MS-/Google-Chromium-libraries - which do all the heavy work under the covers.
And as always:
Please reduce your spamming of this thread -
you now have your very own WebView2-thread here in the CodeBank
(and I'd prefer when you do your "thinking out loud" over there).
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
dim str as string
str=jsProp("document.body.outerHTML")
when webivew is busy
or moretime
it's run slowly,no result back
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
SearchingDataOnly
The fourth question:
(4) I need to place multiple WebViews on my Form or WidgetForm. I bind a WebView to a cwWidget through "WV.BindTo(W.Root.hWnd, 10)".
The question is, when this cwWidget is removed, how to remove the bound WebView at the same time?
in vc++
webviewController->get_CoreWebView2(&webviewWindow) it's com object
set webviewController=nothing
set webviewWindow=nothing
so it will close edge browser in other process background
use control array:
Code:
Web1pic(0).Visible = False
LOAD Web1pic(1)
Web1pic(1).Visible = True
Web1.BindTo(Web1pic(1).hWnd)
remove webview and close edge borwser:
Private Function FrmSubclassProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal uIdSubclass As Form1, ByVal dwRefData As Long) As Long
Select Case uMsg
Case WM_COMMAND
Case WM_DESTROY
end sub
if bindto(hosthwnd),hosthwnd have a msg WM_DESTROY,it will auto close edge webbrowser.
if you bind 3 webview control(web1,web2,web3) only use one hostwnd( bind to same hwnd)
you want to only close web2,mabe need call by rc6.dll for make new Method. or set web2=nothing
Code:
Set Web1 = New_c.WebView2
Set Web2 = New_c.WebView2
Set Web3 = New_c.WebView2
Web1.BindTo(form2.hwnd)
Web2.BindTo(form2.hwnd)
Web3.BindTo(form2.hwnd)
movesize web1 to 0,0,400,400
move size web2 to 0,400,400,800
move size web3 to 0,800,400,1200
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I spent a few hours re-learning the 10 pages that everyone responded to, and learned a lot of new things. I don't know if there are people like me?
I feel that the learning cost of webview2 is very high, and the difficulty is too great. It is more than 10 times more difficult than webBrowser, and the similar functions are less than 5%. Microsoft is really disappointing, and VB.NET has not continued the ease of learning of VB6.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
When starting my app, I want to test if objects and libraries are setup correctly.
To do that I have written some test functions like this:
Code:
Dim obj As Object
Set obj = CreateObject("LibraryRC6.cCairoContext")
If Not obj Is Nothing Then
' Library and class exist
MsgBox "Library and class exist!"
Else
' Library or class does not exist
MsgBox "Library or class does not exist!"
End If
However, that does not work, it throws the error "Active X can't create object".
What would be the correct name to create this object or to check if the library can be used?
I am not sure where to best post this question. If somebody tells me where to do that, I will try to move my post there.
Thank you!
ps: I don't want to use LoadLibrary as this does not check if the dll is registered correctly.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Use error trapping
Code:
Option Explicit
Private Sub Form_Click()
Debug.Print LibraryInstalled
End Sub
' Air code
Private Function LibraryInstalled() As Boolean
Dim obj As Object
On Error Resume Next
Set obj = CreateObject("LibraryRC6.cCairoContext")
If Err.Number = 0 Then
If Not obj Is Nothing Then
' Library and class exist
LibraryInstalled = True
End If
Else
If Err.Number = 429 Then
' Library not installed
Else
' Show an error
MsgBox "Error: " & Err.Description & " (Number: " & Err.Number & ")"
End If
End If
End Function
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
ps: I don't want to use LoadLibrary as this does not check if the dll is registered correctly.
For the record, the correct "Library-Prefix" in a ProgID
(which usually follows the scheme: "Lib.Class")
...is "RC6.cSomeClass"
And the usual Class (which serves as a Main-Entry-Point), is "cConstructor".
So, a CreateObject-based test, should ideally be done via ProgID: "RC6.cConstructor"
That said, you can always work regfree with the RC6, when you:
- ship the recent bunch of RC6(Base)-Dlls, all in a SubFolder of your App(zip)
- and in addition - simply place a "helper-bas-module" in your App-Project.
I've mentioned jpbro's work (related to this regfree-approach) already here in this thread:
https://www.vbforums.com/showthread....=1#post5606658
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Hopefully, this is something simple. Trying to simply set the Background Color of the webview2 page. There is a property for it, but I can't seem to find where it is in the cWebView2 class.
Thanks!
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
BooksRUs
Hopefully, this is something simple. Trying to simply set the Background Color of the webview2 page. There is a property for it, but I can't seem to find where it is in the cWebView2 class.
Thanks!
it's use by css or js
Supports WebDriver, so it also supports various scenarios such as crawlers and automated tests.
Is it necessary to set the proxy IP in the startup parameters or something, and then you can support WebDriver?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Supports WebDriver, so it also supports various scenarios such as crawlers and automated tests.
Is it necessary to set the proxy IP in the startup parameters or something, and then you can support WebDriver?
Automate and test WebView2 apps with Microsoft Edge WebDriver
https://learn.microsoft.com/en-ca/mi...w-to/webdriver
Step 4: Choosing whether Microsoft Edge WebDriver should launch your app or attach to it
Decide whether to configure Selenium to drive WebView2 by using the "launch" or "attach" approach.
The "launch" approach: In some scenarios, it's appropriate to let Microsoft Edge WebDriver handle launching your WebView2 app. Microsoft Edge WebDriver launches your WebView2 app and automatically attaches to the first available WebView2 instance that your app creates.
The "attach" approach: In other scenarios, it's appropriate to attach Microsoft Edge WebDriver to a running WebView2 instance. You launch your app outside of Microsoft Edge WebDriver, and then attach Microsoft Edge WebDriver to a running WebView2 instance. This "attach" approach is for a WebView2 app that's not compatible with the "launch" approach.
https://learn.microsoft.com/en-ca/mi...r-webview2-app
At this point, your app is running and its --remote-debugging-port command-line parameter has been set. Next, we'll attach Microsoft Edge WebDriver to the launched WebView2 app.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
BooksRUs
Hopefully, this is something simple. Trying to simply set the Background Color of the webview2 page.
There is a property for it, but I can't seem to find where it is in the cWebView2 class.
There is not specific property for it on the WV2 ...
The WV2-interface is generally much more "spartan", compared to the old IE-control -
which IMO is a good thing - because the less you have to learn (about the MS-WebView2).
Instead the focus now shifts from built-in COM-methods -
to "easy reachable js-Methods- and -Properties, inside the Browser-engine"
One has to be relatively proficient with JavaScript, to make good use of the WebView2
(and that's a skill, many developers these days already have).
Below is a code-snippet, which uses javascript-property-syntax - to influence the backcolor of the document.body.
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Me.Visible = True 'ensure visibility of this "Parent.hWnd"
Set WV = New_c.WebView2(Me.hWnd) 'bind to the hWnd
WV.NavigateToString "<p>Hello World</p>" 'create a simple document from string-input
WV.jsProp("document.body.style.background") = "red" 'set the body.style.background-pop to red color
End Sub
Private Sub Form_Resize()
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
HTH
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Dear Olaf,
Recently I noticed that if I have two applications (say, A and B) made by me (the 2nd application also invoking webview2 via RC6 WV only), then:
1. If I start application A, the main interface opens normally, rendering the specified web page normally, and everything is working all right.
2. But, even as A is running, if I start B, then 'B' would not start. In other words, the WebView2 rendering engine would not start for 'B'.
So, I searched for a solution in net and landed here - https://stackoverflow.com/questions/...e-same-browser
Seeing the suggestion in the abovementioned link, in 'B', I gave App.path for 'userDataFolder' parameter while binding (as follows):
Code:
WV.BindTo(picWV.hWnd, , , App.Path)
When I did the above and started B, then B also would start simultaneously even while A is running. That made me happy.
I noticed however that a directory named "EBWebView" got created in App.Path of 'B' application. The folders and files carried by that directory occupied 4Mb or so. That's also okay for me as long as 'B' started. But, that made me realise that I need to necessarily give 'App.path' during binding in 'A' application too because otherwise, if an application (say 'X') developed by some other developer was already running in user's system (assuming that 'X' did not have any folder specified for userDataFolder parameter), then if user starts my 'A' application simultaneously, then it would start only if I had specified a folder for userDataFolder in 'A'. But that would mean, 'EBWebView' would get created. "As of now", I don't foresee any problem, "as such", for me or the user because of that extra directory getting created but just wanted to know the following:
--
1. Is the suggestion (say 'S') given in the abovementioned stackoverflow page the ONLY way to start two or more WV-based applications simultaneously?
2. If not, then, what are the alternate ways? Will those ways be better than 'S'? Perhaps they might avoid the creation of the 'EBWebView' but will they be better in terms of speed, etc.?
Note: I do notice that with userDataFolder specified, during the first ever starting of 'A', it takes time for 'A' to start (because of the fresh creation of the 'EBWebView' directory, I believe). But, subsequent starts of 'A' are quite normal.
--
Well, just as I was about to complete drafting this message, I checked the size of 'EBWebView' in 'A' and it was 20MB!!! I checked in 'B' and it was 13MB! So, I think they are growing in size in every start of 'A'. If that is the case, then, it is a cause of concern. I will research more on this growing size when I get time and write back here. It seems like the 'Default' folder inside 'EBWebView' starts growing, probably maintaining some session info, etc.
All said and done, I believe that there should be a proper way to bind by which directories like 'EBWebView' need not get created.
I just now quickly tried keeping different arbitrary values for SecondsToWaitForInitComplete in both 'A' and 'B' to see whether they would help as "settings that differ per-instance". But, in my quick testing, they did not seem to help.
Await a good solution, if any.
OR, in the first place, in case I am wrong in my findings itself, then kindly let me know what mistake I did and what is the corrective action to be taken on my side.
I take this opportunity to once again thank you in TONs, Olaf, for all your wonderful free frameworks/codes/tools and prompt support. God Bless you! God Bless ALL!
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
softv
1. If I start application A, the main interface opens normally, rendering the specified web page normally, and everything is working all right.
2. But, even as A is running, if I start B, then 'B' would not start. In other words, the WebView2 rendering engine would not start for 'B'.
Yep, can affirm that...
...wasn't aware, how the concrete mechanism behind it works - but studied it a bit - and here's what I found:
You have to provide a unique UserData-Directory for:
- executables, which "bytewise differ" (that's probably tested by calculating HashSums in the startup-phase)
Meaning, when you compile executable A.exe - and then:
- just make a file-copy of the same A.exe - just changing the FileName to e.g. "Copy of A.exe"
- this will not cause a conflict, when you start "A.exe" and "Copy of A.exe" in parallel
(when the HashSum of two binaries is the same, they are allowed to share the same UserData-path - with the same "browser-settings").
The "protection" kicks in, when you start executables which differ in their binary Hash-Sum (but point to the same "UserData"-Path).
Then the behaviour is, that "the first one (on this UserData-path) wins".
Hmm - how to solve that in the RC6...
(regarding the "Default-UserData-Path" I apply, when you leave out the optional Param in the Bind-Method)
Currently, I apply the result of: New_c.FSO.GetLocalAppDataPath ... as the "default-UserData-Path" (when the optional Param was not set)
But I could (in the next release) change that, to e.g.: New_c.FSO.GetLocalAppDataPath & "\" & App.EXEName
This way, we would achieve "isolation" between "different App.ExeNames" at least.
If there's better ideas "forth-coming" here, I'd be happy to incorporate them -
if not I'd proceed (for the next version), with what I've just proposed...
Edit: forgot to comment about the "EBWebView"-folder below that UserData-path - #
that's a folder, created by MS - and I wouldn't change its name - or "mess" with any of the content it holds from User-code...
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
Yep, can affirm that...
... .. .
... .. . But I could (in the next release) change that, to e.g.: New_c.FSO.GetLocalAppDataPath & "" & App.EXEName
... .. .
Olaf
Thanks, as always, for your detailed and prompt reply, Olaf.
That's (New_c.FSO.GetLocalAppDataPath & "" & App.EXEName) really unobtrusive too, while being unique. I myself saw the 'EBWebView' folder in my LocalAppData directory today only, after reading your message! :). It was occupying 618MB! Don't know why it is designed to be growing though (by MS)!
Kind Regards.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Hello, what are the dependencies you have, one is CR6.dll but what else?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
LeandroA
Hello, what are the dependencies you have, one is CR6.dll but what else?
Please always ship the whole content of RC6BaseDlls.zip (3.7MB zipped, currently).
RC6.dll depends on DirectCOM.dll, cairo_sqlite.dll, as well as on WebView2Loader.dll (all 3 are "flat Dlls")
I usually put them into a \Bin\ subdirectory below the App.Path (beside the executable) -
and use one of the "Drop-in regfree-bas-modules" to enable regfree deployment of the whole App.
Edit: Here's what a "minimum-version" of such a "regfree-DropIn-bas-module" looks like:
(adjusted, for the libs being contained in the mentioned \Bin\ SubFolder)
Code:
Option Explicit
Private Declare Function LoadLibraryW Lib "kernel32" (ByVal lpLibFileName As Long) As Long
Private Declare Function GetInstanceEx Lib "DirectCOM" (spFName As Long, spClassName As Long, Optional ByVal UseAlteredSearchPath As Boolean = True) As Object
Private Const DirectComDllRelPath = "\Bin\DirectCOM.dll"
Private Const RCDllRelPath = "\Bin\RC6.dll"
Public Property Get New_c() As cConstructor
Static st_RC As cConstructor
If Not st_RC Is Nothing Then Set New_c = st_RC: Exit Property
If App.LogMode Then 'we run compiled - and try to ensure regfree instantiation from \Bin\
On Error Resume Next
LoadLibraryW StrPtr(App.Path & DirectComDllRelPath)
Set st_RC = GetInstanceEx(StrPtr(App.Path & RCDllRelPath), StrPtr("cConstructor"))
If st_RC Is Nothing Then MsgBox "Couldn't load regfree, will try with a registered version next..."
On Error GoTo 0
End If
If st_RC Is Nothing Then Set st_RC = cGlobal.New_c 'fall back to loading a registered version
Set New_c = st_RC
End Property
Public Property Get Cairo() As cCairo
Static st_CR As cCairo
If st_CR Is Nothing Then Set st_CR = New_c.Cairo
Set Cairo = st_CR
End Property
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
thank you very much, it was very helpful
-
Re: VB6 WebView2-Binding (Edge-Chromium)
No spam here. 99% of the questions I ask or reply to are useful or have the correct answer. Maybe a little off topic at times.
For example, someone asked about your previous WEBVIEW problem, why can’t EXCEL VBA be loaded, and why VB.NET will crash after loading? I replied and it was deleted by you. Because the form on VBA is a very special existence, it does not have a handle attribute, even if there is, there are still many problems, so if RC6.DLL itself can provide a window for displaying web pages, VBS can also display the form, VBA is also solved, and VB.NET will not crash.
Didn't we solve that problem in the end?
At this point, you may have said that you have strayed from the topic. Some things are completed in one sentence. If you don’t explain it clearly to you, you will get angry for no reason. I don’t know why. Maybe it’s a translation error?
But you didn't expect me to be very troubled, why RC6.DLL webview always can't display the webpage, the loading is very slow, and the SDK directory cannot be found.
For example, jsprop(**) often fails to return results.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
No spam here. 99% of the questions I ask or reply to are useful or have the correct answer.
Nope, the opposite is the case... 99% of your postings:
- are entirely out of context
- in very bad english
- are for the most part confusing or misleading
- are not reacting to "questions, others were asking you"
Please go "thinking out loud" elsewhere
(but that's probably something, you will not react to either, although you were asked many times).
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Hello, I want to provide some information or perhaps this has already been discussed, if you want to work with dpiAware = true, you can experience that the control does not initialize WV.BindTo() , it is important to take into account that if another application is instantiated using webview from RC6 with dpiAware = true and another application in dpiAware = false the last one will fail and vice versa, note if the IDE is executed, the manifested exe will fail until stopping the ide.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
LeandroA
Hello, I want to provide some information or perhaps this has already been discussed, if you want to work with dpiAware = true, you can experience that the control does not initialize WV.BindTo() , it is important to take into account that if another application is instantiated using webview from RC6 with dpiAware = true and another application in dpiAware = false the last one will fail and vice versa, note if the IDE is executed, the manifested exe will fail until stopping the ide.
That's similar to what softv brought up in #402 ...
and should be fixed now in RC6 verion 6.0.15 - but I've not yet uploaded this new version...
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
how to get selected item html?
Code:
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var clonedRange = range.cloneRange();
var fragment = clonedRange.cloneContents();
var div = document.createElement('div');
div.appendChild(fragment);
var htmlString = div.innerHTML;
console.log(htmlString);
Code:
var htmlString = window.getSelection().getRangeAt(0).cloneContents().querySelector('body').innerHTML;
VM317:1 Uncaught TypeError: Cannot read properties of null (reading 'innerHTML')
at <anonymous>:1:91
why?
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
how to get selected item html?
Code:
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var clonedRange = range.cloneRange();
var fragment = clonedRange.cloneContents();
var div = document.createElement('div');
div.appendChild(fragment);
var htmlString = div.innerHTML;
console.log(htmlString);
Code:
var htmlString = window.getSelection().getRangeAt(0).cloneContents().querySelector('body').innerHTML;
VM317:1 Uncaught TypeError: Cannot read properties of null (reading 'innerHTML')
at <anonymous>:1:91
why?
This is primarily a VB-Forum - and your question is related to "pure Javascript" -
please ask it elsewhere and stop spamming this thread.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
The browser control gets the selected text, HTM, or image, which is like a text box, and it is a very useful function to get part of the selected text. In addition to displaying web pages, web controls also need other JS-related functions.
I have found the code, if it can be added to the DLL, it can make the webview more powerful
In ie webbrowser, almost no JS functions are used, except that if you want to right-click to pop up the menu, you can actually use some undisclosed or special interfaces of WEBBROWSER to achieve it.
However, edge webview2 requires a lot of JAVASCRIPT functions to be more convenient to use. If JS is disabled or JAVASCRIPT is not used, many functions cannot be realized.
Perhaps it is possible to develop another RC6js.dll specifically to enhance JS capabilities, or add a general tools.js to enhance control capabilities, just like jquery.js exists.
Sometimes I also want to get the text at the current mouse position (not selected) or just right clicked.
Sometimes I want to get the coordinates of an element in the webpage ( left,top offset of the webview). There are many functions that are still necessary. If everyone can contribute some good JS functions to enhance the ability of edge, everyone's efforts will be great. Benefit 100-1000 other users.
this is just a suggestion
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
xiaoyao
Perhaps it is possible to develop another RC6js.dll specifically to enhance JS capabilities...
Why would anyone want to do that - when you can load such a "myUseful_JS_helper_functions.js" file
into the WebView2-Context in just one line of code?
This place is for the cWebView2-COM-Class of the RC6 - and javascript-problems should be mentioned only,
when the COM-interface-methods for that (WV.jsProp, WV.jsRun, etc.) make problems.
This Forum has a "javascript-SubForum" ... please post your "js-helpers-xiaoyao-style"
in a separate thread over there.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Has anybody found a smart / easy way to use Olafs webview2 wrapper in Winform .NET?
I wonder if I have to go interop, but I think so.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
Has anybody found a smart / easy way to use Olafs webview2 wrapper in Winform .NET?
I wonder if I have to go interop, but I think so.
I wonder why would you'd go .NET-Winforms (...is there a certain Control, not covered by Krools Suite)?
Well, ... if you really have to - I'd use the .NET-based ("native") WebView2-wrapper instead of the RC6-based one.
Olaf
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
Schmidt
That's similar to what softv brought up in #402 ...
and should be fixed now in RC6 verion 6.0.15 - but I've not yet uploaded this new version...
Olaf
Hi Olaf,
do you plan to release the 6.0.15 with the fix for the DPI aware and DPI scaling issues?
Thanks.
-
Re: VB6 WebView2-Binding (Edge-Chromium)
I would like to block the loading of images.
I am using this after initialization:
WV.AddWebResourceRequestedFilter "*", Filter_IMAGE
However, this event is never called:
Code:
Private Sub WV_PermissionRequested(ByVal IsUserInitiated As Boolean, State As RC6.eWebView2PermissionState, ByVal URI As String, ByVal PermissionKind As RC6.eWebView2PermissionKind)
Debug.Assert False
If Has(URI, "jpg") Or Has(URI, "png") Then
Debug.Assert False
End If
End Sub
-
Re: VB6 WebView2-Binding (Edge-Chromium)
Quote:
Originally Posted by
tmighty2
I would like to block the loading of images.
I am using this after initialization:
WV.AddWebResourceRequestedFilter "*", Filter_IMAGE
However, this event is never called:
Code:
Private Sub WV_PermissionRequested(ByVal IsUserInitiated As Boolean, State As RC6.eWebView2PermissionState, ByVal URI As String, ByVal PermissionKind As
As explained in #373, the matching event is: WV_WebResourceRequested ...
(and not WV_PermissionRequested, which is more for hardware-things like "GPS-sensor-access-permission, Microphon- or Camera-access-permissions")
Olaf