PDA

View Full Version : MS Edge WebView2 ActiveX wrapper



wila
20-Jun-2021, 04:45 PM
Hi,

Over the past weeks I've built an ActiveX wrapper for the Microsoft Edge WebView2 control, which is the follow up for the old cComWebBrowser control from Microsoft.

Quite a bit of its functionality is already available in my control, although I am still working on some of the nitty gritty. It is a huge interface and it will take some time to complete. Not all of it is exactly straight forward either.

The C++ Documentation is here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/?view=webview2-1.0.864.35

However much of what I did has been modeled after the .net interface.. (it is easier to navigate if you ask me)
https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core?view=webview2-dotnet-1.0.864.35&viewFallbackFrom=webview2-1.0.864.35

I have been building against the very latest version of the control and have indeed already benefited from access to the latest features.

What I'm not sure about is what the interest for this is in the DataFlex community.

Just to be clear upfront, it won't be free as then I cannot provide any support on it.
In fact for price, it will be very similar to how Chilkat does its licensing and support.
Price will be similar too (EUR 300), although there will be an early bird deal with 50% off.

I expect to have an early beta demo ready in the next few days (need to write more DataFlex code etc.. test test test)
14697

Let me know if there's any interest.
--
Wil

Marco
20-Jun-2021, 05:07 PM
Hi Wil

Assuming there is screen scraping and automation (setting form values, pressing buttons).

Than yes, seems a fair value!

Mike Cooper
21-Jun-2021, 03:44 AM
Hi Wil

Currently I don't use any browser objects (any more) so 300 EUR is a bit rich for me with no need. HOWEVER, I would likely be interested in the early bird special to keep my option open on this. Are you suggesting that there is an annual fee afterwards for licensing and support?

Mike

wila
21-Jun-2021, 03:58 AM
Mike,


Are you suggesting that there is an annual fee afterwards for licensing and support?

No additional licensing fees or constraints beyond the expected "reselling" limit. Also no built in end dates on the control once purchased.
For support and updates there will indeed be a 1 year limit where you have to buy a new update&support after 1 year.
Not the "forever" updates option that I tend to do for other things.

The reasoning here is that for Microsoft the MS Edge WebView2 control is a work in progress.
They will keep on improving the control and this way I can keep up with their improvements.

Old versions should keep on working. That's a basic premise in ActiveX, they can add & extend, but normally not break old interfaces.
At least that is what Microsoft tells us about ActiveX technology.
As the underpinnings are based on ActiveX, I hope that Microsoft lives by their own rules.

edit: To be more clear. With the early bird special you will get updates for 1 year. So you can take advantage of any new features & fixes implemented in that one year subscription. If you then let lapse the update&subscription you still have a fully functional WebView2 browser control.

Marco: I will answer your question later today.
--
Wil

Mike Cooper
21-Jun-2021, 06:20 AM
Thanks Wil.

Sounds fair.

wila
21-Jun-2021, 08:45 AM
Marco,


Hi Wil

Assuming there is screen scraping and automation (setting form values, pressing buttons).

Than yes, seems a fair value!

Ah.. an easy question from Marco.. with a long answer...

Define screen scraping. I think I know what you are asking, but it can be a picture, or the html that comes from the server, or it can be what is rendered in the browser (eg. the source might have been - is even likely to have been - changed via javascript). For my answer here I'm going to assume it is the latter.

Let's step back a bit.

With the old webBrowser activex control from Microsoft you would get direct access to the DOM from within the browser control and thus DataFlex.
Eg. there's the ComDocument function that returns variant variable that you can then connect to a cComHtmlDocument object via the mshtml ActiveX interface.
This was very powerful and it allowed you to do all kinds of magical things.

That's not how the WebView2 control works. While you could technically still use mshtml for generating html, it doesn't make as much sense and there isn't a way to connect it to the control. You could load the result as a string though.
Besides that mshtml (https://en.wikipedia.org/wiki/Trident_(software)) is AFAIK a part of the old browser control, so it is marked obsolete as well.

With WebView2 you are able to get the data that is send over the line.
But it creates a new task for each file that your page is made up of and returns each task as an IStream object.
From what I've seen so far, these IStream objects don't have an indication if they are returning a string or a bunch of bytes (for example a picture), the name structure is not filled in my tests either.
I'm now offering this resource result event as a string, but that might not make a lot of sense in most cases.
Besides that... even if you would know what goes over the line, things get cached and a reload of your page doesn't get as much data as the first request might have done. Messing with the content mid stream.. also not that recommended.
So that is also a dead end for this type of thing.

Is there nothing that can give us a "scrape" of what is in the browser?

Yes, actually there is.
As you know, we live in a javascript world nowadays :)

There's an "executeScript" method which allows you to run javascript in the document that is currently displayed in the browser.
This also triggers an event with the result of that javascript call.
You can use that to retrieve the document content, fill particular parts in the html and even do things like trigger button clicks.
From what I see now and my preliminary tests with that, it should work OK.
I will see if I can add this as a demo to the DataFlex application.

However for the moment I'm focusing on the base ActiveX wrapper, not on manipulating what is rendered in the browser.
It is possible to add that type of thing later on, but it is not actually a native msedge WebView2 feature.
At least I haven't seen it.

Hope this helps,
--
Wil

Tom Murphy
22-Jun-2021, 02:40 AM
Hi Wil

That's looking pretty good Wil, nice work! Talking mshtml and the DOM, have you attempted to use your tinyMCE interface in Web View 2 yet?

wila
22-Jun-2021, 03:21 AM
Marco,

Last night I played a bit with this.
As some of it can be challenging, like the json object encoding of the results and additional error checking, I do see value in adding this right away.
So I will add an additional automation interface for easy manipulation (this will push my time lines a bit, but oh well...)

Thanks for the suggestion.
--
Wil

wila
22-Jun-2021, 03:23 AM
Hi Tom,

Nope, just trying to focus on the main parts first before I even entertain ideas like that.
It should be possible though.
--
Wil

Tom Murphy
22-Jun-2021, 10:39 PM
Hi Wil

I thought that may be the case.. but it's nice to know there looks like there's a pathway forwards.

wila
30-Jun-2021, 04:31 PM
Hi,

So... Marco's request revealed some real nice things... a bit like a box with Pandora written all over it. :D
The thing is that with the WebView2 control pretty much everything is asynchronous. This is particular nasty for the javascript part as it quickly becomes a question which javascript function returns the data if you run 2 around the same time..
I found a solution for that and will expose that for custom functions before release as well, a programming API that is indeed still asynchronous, but not that hard to use. FWIW, I tried for a while to rewrite it to make it synchronous, with threads etc.., but that won't work with this control.

Also note that all the results from a javascript call are in JSON. Not the pretty JSON you are used to see, but escaped JSON. While DataFlex's JSON class can deal with some of that, it doesn't take care of all, so I also added a JSON to string function (DecodeJsonObjectString) that is exposed as well.

But, Marco got what he asked for and I'm pretty convinced it will be very useful later on as well, something to expand upon.

The Tech Preview is available as of now from here:
https://antwise.com/Edge-WebView2-ActiveX.htm

It has been tested with DataFlex 19.0 and DataFlex 20.0.
It looks like that 64 bit even works, but ... that has not had a lot of tests (it compiled, it ran... I clicked around, it didn't crash...)

There's going to be issues, I have no doubts about it, but -then again- it is a preview.

Either way, it is pretty cool to see the MS Edge WebView2 control run in DataFlex.
--
Wil

wila
1-Jul-2021, 03:24 AM
Ack.. I buried my release announcement in a wall of text.
Just to be clear:

The Tech Preview is available as of now from here:
https://antwise.com/Edge-WebView2-ActiveX.htm

--
Wil

Marco
1-Jul-2021, 05:21 PM
Thanks Wil

Sounds like some great work
Is done. I’m in the last days before a two weeks camping in the outback, so won’t have time to look at this yet.

But am very excited of the work you have done and am looking forward working with it after my holiday.

Cheers from OZ

DaveR
2-Jul-2021, 10:16 AM
Thanks Wil

Sounds like some great work
Is done. I’m in the last days before a two weeks camping in the outback, so won’t have time to look at this yet.

But am very excited of the work you have done and am looking forward working with it after my holiday.

Cheers from OZ

The outback where everything can kill you? (hmmm, that applies to the Steakhouse too)

Be safe...

Stephen W. Meeley
6-Jul-2021, 06:40 AM
To all,

When Wil first announced this work, we shared information with him about our parallel project to include WebView2 in the next revision of DataFlex (20.1). We started our own project before we even knew about Wil’s (and visa-versa).

Our work is in progress at this time and we are not ready to provide further details (please don’t ask). What we can tell you is that a main difference between the projects is that we are implementing it for 20.1 (and higher) only, not attempting to publish and support it for existing revisions of DataFlex.

After further consultation with Wil, we both wanted you to know that DAW is developing in this area too. We encourage you to take a serious look at Wil’s component as it is available now (though not yet fully released) for existing revisions.

wila
6-Jul-2021, 07:12 AM
Thanks Stephen,

I think that it is great that you guys are sharing this info early to the community, so that everyone can make the best decision on what they want to do going forward.

Also really appreciate the heads up I got from DAW after my announcement I was working on this, so that I could make a better judgment on going forward with this control or not.
As explained to DAW in those emails, I needed the control right now already anyways. Extending the control beyond my current needs was just a challenge :)

As pointed out by SWM, one of the differences from the start is that my WebView2 wrapper can be used in any DataFlex version.
Not only that, as it is an ActiveX component, it is also available for developers outside of the DataFlex community.
I'm also pretty sure that both of our controls will be different in implementation details and that those differences will only get larger over time.

All in all, very happy that this is now in the open.
Having more choice can't be a bad thing ;)

cheers!
--
Wil

wila
24-Jul-2021, 06:06 PM
Hi,

Here's the Tech Preview 2 update - version 1.0.44 - that I just released.

This is a major update and it includes a new way to interface with javascript from within your DataFlex applications, it is called "RunAnonymousFunction" for running.. anonymous javascript functions.
But it's a little more than that.

It makes the whole experience really a lot easier and much more clean than the original "run an async script" API that is offered by Microsoft.
Of course the API is still asynchronous, but you can now see which call made the original request.
This means that if you run multiple javascript calls at the same time, that you can actually see which call triggered the event that returns and passes you the result.
It also means that instead of handling everything in one big event and having to add your own additional logic to determine what is what, you can now split out your logic per function based on what you receive. This keeps your code much cleaner.

Another improvement there is that you can pass parameters to your javascript function via a variant array.

A selected snippet from one of the examples in the demo might help to illustrate the above:


Define CFun_QueryCurrencyRate for 6
Define CFun_RateReceived for 7

Procedure QueryRatings
String sScript
Integer iErr
Number nAmount
String sCurFrom
String sCurTo
Variant[] Params

Move "" To sScript
Append sScript "(amount,curFrom,curTo) => {" CS_CRLF
Append sScript " displayGraph(curFrom,curTo);" CS_CRLF
Append sScript " let obj = document.getElementById('currencyRate');" CS_CRLF
Append sScript " if (obj !== undefined) {" CS_CRLF
Append sScript " obj.innerText = '-1'" CS_CRLF // -1 is initialized..
Append sScript " }"
Append sScript " queryRates(amount,curFrom,curTo);" CS_CRLF
Append sScript "}" CS_CRLF
Send ConnectBrowser to oDocument
Get Value of oAmountForm to nAmount
Get Value of oFromCombo to sCurFrom
Get Value of oToCombo to sCurTo
Move nAmount To Params[0]
Move sCurFrom To Params[1]
Move sCurTo To Params[2]
Get ComRunAnonymousFunction of oDocument CFun_QueryCurrencyRate Params sScript to iErr
End_Procedure


Being able to pass your parameters via the variant array (Params) makes communicating with javascript functions so much more natural.
Instead of CFun_QueryCurrencyRate, you can of course also just use a number to identify your script, I just prefer to name my numbers.

The triggered async event then can look like this:


Procedure CurrencyRateResult Variant[] llParams String llData
Number nRate
Number nAmount
String sCurrency
Move llData To nRate
If (nRate <> -1) Begin
// more code here
End
End_Procedure

Procedure OnComRunAnonymousFunction Integer llId Variant llParams String llData Integer llError
If (llId=CFun_RateReceived) Begin
Send CurrencyRateResult llParams llData
End
End_Procedure


Your event can pass the parameters that the original anonymous function had as well, but by default this is disabled for performance reasons.
It won't make much difference when passing a few parameters, but if you passed large strings for data then it can actually make a difference.

Here's a link to the list of changes:
https://antwise.com/antEdgeWebBrowser-changes.htm

and the control plus demo (with some really cool new examples) is available here:
https://antwise.com/Edge-WebView2-ActiveX.htm

cheers!
--
Wil

edit: some screenshots of the new demo's (made by Oy, her expertise has been very helpful for many times while working on this control, and not only for the demos).
1475714758

Mike Cooper
25-Jul-2021, 06:56 AM
Thanks Wil

You had mentioned an "early bird" special price. Is this available yet for us to chip in?

wila
25-Jul-2021, 07:17 AM
Hi Mike,


Thanks Wil

You had mentioned an "early bird" special price. Is this available yet for us to chip in?

It is not available for sale yet.
The early bird special will come once you can buy the control, this is still a tech preview where you can play with what's available and get an idea with how everything works without having a trial period where the clock starts ticking. (There is a hardwired expiry date at 21 August, but it does not count for the trial period once released)

Hopefully I am able to release within the next few weeks, the control itself is getting pretty close to that stage now and if not then there will be a TP3 or RC before the 21st of August.
--
Wil

Mike Cooper
25-Jul-2021, 10:12 AM
Thanks Wil

wila
24-Aug-2021, 04:35 PM
Hi,

Going from beta to live was a bit more work as I anticipated. :)

However as of now, the new control is available and has been renamed as: AntView
(https://antview.dev)There's a pretty new website, help, an installer... oh lala!
It even ended up as a product in the webshop.

The list of changes since last update:

2021/08/25

release 1.0.63
- Updated the installer script as it did not put the help file in the correct spot in the start menu (expected was AntView .. reality was Vimarun .. oops).
So now you can find the windows help file too.

2021/08/24

release 1.0.62
- Added functions for licensing, DemoDaysLeft, UnlockStatus, UnlockControl.
- Changed EDGEWEBVIEW2_WEB_ERROR_STATUS_ error constant prefixes to wes, eg. EDGEWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN is now wesUnknown, which is more in line with the rest of the code.
- Added event onScriptDialogOpening.
- The UserDataFolder logic now uses the default Microsoft logic for creating a default caching folder. This means that by default it will create a folder named {app.exe}.WebView2 folder. This is because 2 separate applications hosting the WebView2 control cannot share the same caching folder. This is configurable (see the help).
- Removed beta logic
- Changed the product name from AntEdgeWebBrowser to AntView as the former is too hard to pronounce.
- Renamed EdgeWebBrowser itself to AntView
- For all the classes the "EdgeWebView2" part in their names has been renamed to "AntView".
- Last minute name changes on a few functions to make them a closer match with the native .net interface from Microsoft.
This should make it easier to find help online and not get confused by different naming schemes.
- Removed LoadHtml function, as it did not set the referer contrary to promise, so it is better to use NavigateToString instead.
- The OnExecuteScriptResult event is now called OnExecuteScript (shorter=better)
- Added new logo & website
- Wrote installer
- Wrote first version of help
- Updated demo's to use new name of the control, fixed a localisation issue in the ExchangeRates demo view.

so for the new control have a look at https://antview.dev !

Cheers!

--
Wil

Nils G. Svedmyr
25-Aug-2021, 02:02 AM
Congratulation Wil to the release!

I've been eagerly awaiting this release and have just installed it and are about to start testing and implementing it for an existing system.

I want to purchase a license right away. Do i then get license number one? :)

wila
25-Aug-2021, 03:57 AM
Nils,

LOL

Thanks Nils.

If it had license numbers than yes, it would be license number 1, or maybe 2 as I'm using the control for one of my own customers as well ;)

--
Wil

chuckatkinson
26-Aug-2021, 01:55 PM
Thanks Wil. My customer just bought a copy ( license #3?)

For the UserDataFolder you might want to clarify the Online help. It should be done in OnComCreate. OnCreate is too late.

MisterM
26-Aug-2021, 02:13 PM
Speaking of Chuck's customer...

If it's helpful for anyone, here's the file and class info for the .OCX control you can paste into your .exe.manifest files if you want to deploy using Side-By-Side registration. It was created using a tool called regsvr42 (https://www.codeproject.com/articles/28682/regsvr42-generate-sxs-manifest-files-from-native-d) against the current release, 1.0.63:



<file name="antview.ocx">
<comClass description="EdgeWebView2WebResourceRequestedEventArgs Object" clsid="{0C2BFE58-1A8A-4D83-89B1-3095E0AB036C}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2NewWindowRequestedEventArgs Object" clsid="{C2ABDE17-C1DE-4BD3-AC47-9CF75D16F918}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2SourceChangedEventArgs Object" clsid="{CFEDFEF8-9B03-48BA-9566-516163DF4EA3}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2ProcessFailedEventArgs Object" clsid="{9F41340F-4E38-419D-90F4-1CF790706782}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2PermissionRequestedEventArgs Object" clsid="{D6F6EF34-5CD0-4DCD-848C-720FA9AB93AC}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2ScriptDialogOpeningEventArgs Object" clsid="{9EA17BDA-36FB-47B4-A4F9-C0A29A154A69}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2DevToolsProtocolEventReceiver Object" clsid="{66617E01-BE7B-4910-86DF-B4C241D2AF1F}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2DevToolsProtocolEventReceivedEventArgs Object" clsid="{81BBF01A-0C6B-4221-B7DC-E5D0A3E843EF}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2EnvironmentOptions Object" clsid="{D011D6A6-F958-4B89-AC3B-09673973D2C4}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2Environment Object" clsid="{0AA87ED3-C9BD-44A3-A18D-E507DE6B7B27}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2WebMessageReceivedEventArgs Object" clsid="{712B1A3C-C5C0-4D44-91B0-0E454AD07256}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2HttpHeadersCollectionIterator Object" clsid="{CE0AE45A-BF24-4668-92FF-5AA64F34B5EF}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2ContentLoadingEventArgs Object" clsid="{CF64BDD2-7770-49F5-A68D-40827CC3F190}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2NavigationCompletedEventArgs Object" clsid="{04A54D10-27B5-48C2-AE86-11F398F55523}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2HttpResponseHeaders Object" clsid="{C00CD9F2-BBEF-4B5E-9D3D-BE08D09157D5}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2HttpRequestHeaders Object" clsid="{C225455F-55B8-49A2-9246-9A7BB26F577E}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="MS Edge WebView2 Browser Control" clsid="{7E146B1D-42ED-4386-904F-9A9EDB61F9AE}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="AntViewDocument Object" clsid="{D89731D5-058C-4768-8CBA-386BE21BE090}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="TPropertyPage1 property page" clsid="{90B91CAC-E369-4C9B-AF4B-39AFA824FC73}"></comClass>
<comClass description="EdgeWebView2WebResourceResponseView Object" clsid="{4C0264E5-C49A-4B33-A3A1-AFE9B682601C}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2WebResourceRequest Object" clsid="{14C5B071-526F-46BA-A8B2-D6926DAF5FB6}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
<comClass description="EdgeWebView2NavigationStartingEventArgs Object" clsid="{3326D4EF-884E-4EF7-A61F-8E5AB4862990}" threadingModel="Apartment" tlbid="{D4278A43-021B-4C82-9C1F-D6A6FA39851C}"></comClass>
</file><!--End antview.ocx-->



Seems to be working for me, at least so far...

Nils G. Svedmyr
26-Aug-2021, 02:18 PM
Or you could use the COM Manifest Studio to do that :rolleyes:

MisterM
26-Aug-2021, 02:24 PM
Or you could use the COM Manifest Studio to do that :rolleyes:

That's probably better, yeah. But it didn't show up in my Googling of "SXS manifest register OCX", so I used what I could find easily...

Nils G. Svedmyr
26-Aug-2021, 02:27 PM
I see. You find it on https://www.rdctools.com under Downloads. Or if you're interested of the latest version for 19.1, send me an email on nils dot svedmyr at rdctools.com.

Mike Cooper
26-Aug-2021, 04:17 PM
Thanks Wil!

wila
26-Aug-2021, 06:32 PM
Hi Chuck,

Thanks.

The documentation is written with more than just DataFlex in mind.. You might notice in the doc (https://doc.antview.dev ) that none of the methods have the "Com" prefix.

In DataFlex we unfortunately have both OnCreate as well as OnComCreate...
The OnCreate is from the DataFlex framework whereas OnComCreate is from the control... On hindsight a tad confusing.
So yes, the documentation could use more work, no doubt about that (ha! .. we didn't even have doc on Saturday).

As far as the cache folder goes (or UserDataFolder), I'm in the process of adding an extra option there to change the default.
Right now you're getting Microsoft's default and while they are also working on changing that (see https://github.com/MicrosoftEdge/WebView2Feedback/issues/1410 ) waiting for that is probably not the best choice.

However as they are going to put the cache folder in another weird spot and as we don't know when that change will land... I'm adding a bit of logic for a default that will work better for most of us in the next update (around next week)

As a bit of background, earlier today I was playing with getting the control to work in MS Excel ( https://twitter.com/wilva/status/1430864344234045440 ) and that works, but .. the worksheet fires the onCreate and onActivate too early, you can't catch those events in the VBA script.
So I worked around that by using the user temp folder instead ( <usertemp>\{appname}.WebView2\ )
eg in this case:
'C:\Users\Wil\AppData\Local\Temp\EXCEL.EXE.WebView 2\'

I think by using that naming scheme it will work better for most DataFlex developers than the current one which clutters up space in the program's folder.

--
Wil

wila
26-Aug-2021, 06:37 PM
Hi Mark,

That's one area I have not had the time to investigate.

Those description fields will change btw, but it shouldn't break your SxS registration as that's done by clsid and I won't touch those.
--
Wil

chuckatkinson
27-Aug-2021, 05:19 AM
In case it helps. This is what we are doing.



//Sets the user data folder for the cache
Procedure OnComCreate
String sUserDataPath


Get_Environment "APPDATA" to sUserDataPath
Append sUserDataPath "\AIM"


Set ComUserDataFolder to sUserDataPath
End_Procedure




AIM is the general app name.

wila
27-Aug-2021, 05:29 AM
Thanks Chuck.

That will continue to work as is.

As in, that I will change the default location to the local user temp path, but only if you do not explicitly set the UserDataFolder like you are doing here.

--
Wil

chuckatkinson
27-Aug-2021, 05:47 AM
Using that I get C:\Users\SomeUser\AppData\Roaming as the base folder path.

Do you see any issues with using this path?

wila
27-Aug-2021, 06:00 AM
Chuck,


Using that I get C:\Users\SomeUser\AppData\Roaming as the base folder path.

Do you see any issues with using this path?

I expect no issues with that.
The issue feedback link (https://github.com/MicrosoftEdge/WebView2Feedback/issues/1410) from MS I provided earlier has good background info about the reasoning behind the choice for folder location. I will try to condense that info in the documentation.

Note that if you have multiple applications using the control that they then do need their own caching folder.
The WebView2 control complains if you have multiple executables trying to use the same path.

--
Wil

chuckatkinson
27-Aug-2021, 06:41 AM
Wil,

Thanks. I've now changed to below. Wondering what happens if the user runs multiple instances of the same program?



Procedure OnComCreate
String sUserDataPath sProgram


Move (Module_Name(Desktop)) to sProgram

Get_Environment "APPDATA" to sUserDataPath
Append sUserDataPath "\AIM\" sProgram "\"


Set ComUserDataFolder to sUserDataPath
End_Procedure

wila
27-Aug-2021, 07:49 AM
Chuck,

Good question and one I actually had looked for answers in the documentation earlier on, but not found an answer.

The control itself allows it, whereas if I rename the binary it does not.
Say we have "Demo.exe" and "Demo2.exe" then the moment I start the second app - while sharing the same folder - there's an error "The group or resource is not in the correct state to perform the requested operation".

OTOH, when I start Demo.exe more than one time, there is no error and it all appears to work.
However, I don't know if it is a safe thing to do and as such I have forwarded your question on that same feedback thread at github.

PS: I'm starting to wonder if I should setup some forum software for Antview ;)
--
Wil

chuckatkinson
27-Aug-2021, 08:31 AM
Wil,
I'd be interested in the responses.

We have users that fire up the same app multiple times. We will be testing for any errors and I will let you know.

Thanks !

wila
27-Aug-2021, 03:54 PM
Chuck,

That seems to be fine.

More details here:
https://github.com/MicrosoftEdge/WebView2Feedback/issues/1410#issuecomment-907174261

--
Wil

chuckatkinson
29-Aug-2021, 10:14 AM
Thanks Wil.

User testing will continue next week. So far everything is fine.

wila
29-Aug-2021, 11:47 AM
Thanks Chuck, glad to hear.
Your feedback is welcome and does help.

The WebView2 control itself is interesting and offers a lot of functionality.
I'm quite happy with the AntView control in the project where I am using it for a customer.
Over time I will continue to expose more of the underlying capabilities the WebView2 control offers.

--
Wil

chuckatkinson
30-Aug-2021, 09:40 AM
Wil,

After reading a bit on the MS GitHub forum and the other MS docs. I have now changed the folder to go down to the view and object level. So each instance of the web browser will at least have it's own it's own folder. We don't control running multiple instances of the same app but at least the control for the view will have it's own cache folder. I think it's the best we can do at this time until or if MS does some further work on this folder.

wila
30-Aug-2021, 04:03 PM
Chuck,

I think the whole discussion about the user data folder is unnecessarily complicated and is in most cases pretty much irrelevant.
This weekend I spent a lot of time on simplifying the logic, extending the doc and changing the default - if not set.

Let me try to explain.
First off.. let's call it what it is: a user data folder and not a cache folder. Yes it also contains cache files, but the more important parts it contains are things like cookies and internal database structures (for example the indexedDB files are there)
My mistake to call it a cache folder as it is more than that.

Then think of this like your browser. It is fine if your browser visits multiple pages.. that's what browsers do.
No need to separate/isolate each user data folder per object in your application. That just complicates things. The WebView2 control follows the same rules as browsers do, cookies from other domains cannot be read. It obeys things like CORS (what a pain that it does :D ) so the need to separate is as big as it is with a normal browser.
Not that big.

Why is it in a different folder then?
Well that's because it cannot share folders with MS Edge. Not everybody uses the same version for the WebView2 control as the MS Edge browser.
I recommend to use the same version, but this is the idea behind it. Some developers don't like the idea that the control gets updates and might change in how it works. (To be honest, this is how it has ALWAYS worked with internet explorer WebBrowser control, so not sure what the scare is about)
The data structures in the user data folder of the WebView2 control and the MS Edge browser might not match.
You can even run multiple versions of WebView2 control on your machine (as you can lock down the version) and this is why MS wants to keep the user data folder per application.

So in order to prevent issues with that Microsoft has decided to have the control take care of its own data folders.
That's it.

So what I'm doing in the next update is to create by default the user data folder per application under the user temp folder.
That will work great for most use cases.

Unless... you need things like:
- preserve cookies over time (close the application, re-use the same cookie next time)
- preserve indexedDB (think of SPA - Single Page Application - for example)
Even then it will work just fine... until the system decides to clean up the temp folder as then the cookies are reset and your indexedDB, local storage and session storage gets rebuilt from scratch.

This cleanup is in my experience is pretty rare.
For example I just ran Windows 10 - Storage Sense Cleanup and asked it to cleanup my temporary files and it did not touch the user temp path (C:\Users\Wil\AppData\Local\Temp ) at all, only the system temp path.

There might be another scenario, you wanting to clean up the user data folder. The UserDataFolder property will give you the path that is used and after all the controls are destroyed you can cleanup / remove those user data folders. (You could use CloseBrowserProcess for that)

Sorry for the long story and I hope it helps explaining a bit what this is all about.

--
Wil

Nils G. Svedmyr
31-Aug-2021, 12:15 AM
Very interesting reading, thanks Wil!

wila
31-Aug-2021, 03:52 AM
Hi Chuck,

from here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/user-data-folder#share-user-data-folders



Note

Each WebView2 browser process consumes additional memory and disk space. Therefore, we recommend not running a WebView2 control with too many different user data folders at the same time.


It is probably the text just above it that is confusing you about going with a separate data folder per WebView2 control.
Think of them as different browser tabs.

Having one user data folder is the better option IMO.
--
Wil

chuckatkinson
31-Aug-2021, 07:41 AM
Thanks Wil,

That's a very detailed explanation. It's not too late as we have not released our apps with the control. I'm going to take this advice and move the folder to TEMP and use just a single one for the user.

Thanks again !

wila
31-Aug-2021, 09:55 AM
Chuck,

That will be the default (no need to set the UserDataFolder anymore) in the next update.

In the update there's a new property "DefaultUserDataFolderLocation" that can be set to udflUserTempFolder (the default, new behavior) or udflApplicationFolder (old behavior). If Microsoft then decides to change this as they promise there will be another udflSomethingSomething constant to choose that.
Normally I expect that the default will be fine.

Hopefully release this week. I'm done testing that part, but I am rebuilding the example in Excel with VBA and that did result in some interesting findings and patches, specifically needed for that environment, not changing behavior besides the above.

The help file has more details once the update is released.
--
Wil

chuckatkinson
1-Sep-2021, 07:49 AM
Thanks Wil,

Of course we sub-classed your wrapper so it will be easy to take out our code after the update.

After a lot of user testing we went live with the browser yesterday.

Thanks!

wila
6-Sep-2021, 10:19 AM
Hi,

The update has been released, see also:

https://antview.dev/news/

This update includes a demo built in Microsoft Excel and it also has the changes that I discussed earlier on in this thread about UserData folder.
More details at the link above.

cheers!
--
Wil

wila
10-Nov-2021, 02:56 PM
Hi,

Antview version 1.0.74 has been released.
(https://antview.dev/news/)
The update fixes an issue with using Tab/Shift-Tab to navigate out of the control as well as adds new functionality, such as webmessage support.

See the following link for more details:

https://antview.dev/news/

Please note that users of older versions of DataFlex 19.1 will need to add an extra line to their application in order to compile. The reason for that is that the variant type OLE_VT_UI8 was not declared in earlier DataFlex versions.
However this is an existing Windows variant data type and as such it works fine after declaration.

eg. add the following line before including the cComAntview.pkg file:


#IF (!@ < 191)
Define OLE_VT_UI8 for 21 // 8-byte unsigned int
#ENDIF


--
Wil

wila
29-Nov-2021, 09:55 AM
Hi,

Antview version 1.0.88 has been released.
(https://antview.dev/news/)
The update fixes an issue with a double free on OnWebMessageReceived and adds improved support for Visual Basic.

New functionality is an ability to enable logging for troubleshooting purposes as well as a bunch of new methods for using the Chrome DevTools Protocol.

The demo's have also been improved.

See the following link for more details:

https://antview.dev/news/

(https://antview.dev/news/)cheers!
--
Wil

wila
29-Nov-2021, 02:20 PM
Hi,

Antview version 1.0.88 has been released.

If you already downloaded the new version.. Then you might have downloaded the previous version.
Somehow, it was still pointing to the 1.0.74 setup.

The link has been fixed!

--
Wil

wila
30-Nov-2021, 01:58 PM
Hi,

Another update 1.0.89 as I had messed up ..

Fix changed behavior for OnCreateWebviewCompleted as it was now send one time too often before the WebView was created due to a missed begin/end clause after adding the logging logic.

While that might not really be sufficient for a new release, as it was fairly easy to work around, I really do not like it when a component suddenly behaves different after an update. So that is patched if you need it.
Otherwise .. test via function "WebViewCreated" if the WebView2 control was created, which would have been a good idea anyways.

--
Wil

wila
8-Mar-2022, 03:29 PM
Hi,

Antview version 1.0.111 has been released.
(https://antview.dev/news/)
New features:
- Now supports PrintToPdf
- A few properties for controlling shortcut keys as well as how the browser control should control autofill and autosuggest.
- Uses a newer WebView2Loader.dll

See the following link for more details:

https://antview.dev/news/

(https://antview.dev/news/)cheers!
--
Wil

wila
12-May-2022, 10:52 AM
Hello,

A new update of AntView, version 1.1.164 beta has been released.

This is an important release as it has many new exciting features such as improved VB6 support (which I won't list down here for some reason)

Then the following new features:
- A global interface for setting defaults of all AntView objects
- download management
- new window event handling (for example to redirect window.open requests)
- permission request handling
- client certificate support
- failure handling via the onProcessFailed event
- added Pdf printing completed event
- Single Sign On support via the main host OS account
- Passing so called "Chrome flags" for additional features such as disabling the GPU hardware acceleration (useful on some virtual platforms) or setting a proxy server.
- Changing the Language of the UI
- additional focus handling

Also note that it has some changes in behavior.
Please read: Important changes in AntView 1.1 (https://antview.dev/releases/important-changes-in-antview-1-1/) as that article contains important tips for when you are upgrading and explains what has changed.

You can download the new version from: https://antview.dev/downloads/

The release notes can be found here: https://antview.dev/news/

We expect a new -non beta- release within the next few weeks, depending on the feedback.

If you have any questions or remarks then please let me know.
--
Wil

wila
27-May-2022, 02:40 AM
Hi,

Release of version 1.1.174

Bug Fix/Changed behavior

- Setting UserAgent property is now also cached, so that you can set it before the WebView2 control has been created.
- NavigateWithWebResourceRequest now supports setting headers.

New functionality:
The AntViewDocument interface now has synchronous wrapper functions for each asynchronous function available. This makes it easier to use as well as opens this functionality to environments such as PowerBuilder and OpenText Gupta Team Developer.
Added the following functions:
- RequestCurrentHtmlSync
- RequestElementValueByIdSync
- RequestElementValueByNameSync
- RequestFormSubmitByIdSync
- RequestFormSubmitByNameSync
- RunAnonymousFunctionSync
- SetElementValueByIdSync
- SetElementValueByNameSync
- SynchronousTimeOut property

Demo

- The DataFlex demo has a new postData view.
- Added a demo for PowerBuilder users.

More details can be found at https://antview.dev/news/
--
Wil

wila
14-Jul-2022, 08:45 AM
Hi,

Another release of the AntView control.

This one adds full iframe support.

Release 1.1.200

New functionality:

AntView interface
- OnDOMContentLoaded/OnDOMContentLoadedHex
- OnFrameCreated

New AntViewFrame interface for directly interacting with iframes.
Properties:
- Destroyed
- IDispatchPointer
- Name
Methods:
- BrowserDispatch
- ExecuteScript
- PostWebMessageAsJson
- PostWebMessageAsString
Events:
- OnContentLoading
- OnContentLoadingHex
- OnDestroy
- OnDestroyed
- OnDOMContentLoaded
- OnDOMContentLoadedHex
- OnExecuteScript
- OnNameChanged
- OnNavigationCompleted
- OnNavigationCompletedHex
- OnNavigationStarting
- OnWebMessageReceived
- Added AntViewNavigationStartEventArgs2 for extending the navigation structure data:
- AdditionalAllowedFrameAncestors, which is used by iframes.

AntViewDocument interface
- FrameDispatch, this method allows you to connect the document interface to an iframe object.

AntViewDownloadOperation interface
- OnDestroy event

AntViewWebResourceResponseView interface
- OnDestroy event


Bugfix/Changed behavior
- The Synchronous methods from the document interface cannot be run from within an event due to the nature of how it works. This now returns an error indicating the reason instead of just locking up.
- Fixed AntViewNavigationStartEventArgs.RequestHeaders
- returning a boolean value via runAnonymousFunction would crash the control. This has been fixed by also supporting boolean return value and casting that to a string. Also extended exception handling on this so that the control no longer crashes if it cannot cast the result to a string.
- OnPermissionRequested was broken as state did not work as expected.

There has also been a lot of work done on the documentation, more details - as always - can be read over at https://antview.dev/news/

cheers!
--
Wil

wila
6-Jan-2023, 07:40 AM
New release of AntView.

Release 1.1.236

New functionality:

AntView interface
Properties
- SynchronousTimeOut
Methods
- AddWebResourceRequestedFilter
- CreateWebResourceRequest
- CreateWebResourceResponse
- CreateWebViewSync
- NavigateSync
- NavigateToStringSync
- RemoveWebResourceRequestedFilter
Events
- OnAcceleratorKeyPressed
- OnWebResourceRequested

AntViewDocument interface
Methods
- RequestCurrentText
- RequestCurrentTextSync
- RequestPrint
- RequestPrintSync
Events
- OnRequestCurrentText
- OnRequestPrintCompleted

AntViewNewWindowRequestedEventArgs interface
Properties
- Deferral

New AntViewDeferral interface to be able to postpone destroying of objects so you can complete tasks
Method
- Complete
Events
- OnDestroy

New AntViewPhysicalKeyStatus to assist with OnAcceleratorKeyPressed
Properties
- IsControlKeyDown
- IsExtendedKey
- IsKeyReleased
- IsMenuKeyDown
- IsShiftKeyDown
- RepeatCount
- ScanCode
- WasKeyDown
Events
- OnDestroy

New AntViewWebResourceRequestedEventArgs interface to assist with OnWebResourceRequested and Filters
Properties
- Deferral
- Request
- ResourceContext
- Response
Events
- OnDestroy

New AntViewWebResourceResponse interface to assist with AntViewWebResourceRequestedEventArgs interface
Properties
- Headers
- ReasonPhrase
- StatusCode
- DefaultInterface
Events
- OnDestroy

Bugfix/Changed behavior
- Fix installer issue trying to register 64 bit version of AntView when running on a 32 bit operating system.
- The logging functionality now supports more detailed logging by setting LogMode to level 2. At level 2 more details are logged such as URL's and all the triggered events. It does not include sensitive information such as certificates or html contents (unless you NavigateToString).
- The help documentation has been revised to include more details and be easier to navigate.

For more information please see our "News (https://antview.dev/news/)" page.
--
Wil

wila
20-Feb-2023, 08:03 PM
It's been a few weeks... so figured it is about time for a new release :)

Beyond the added functions to the core control (AntView) there's a whole new cookie manager interface to deal with them pesky cookies.

2023/02/21

release 1.1.270

New functionality:
AntView interface
Properties
- BrowserProcessIDLong
- CookieManager
- IsDocumentPlayingAudio
- IsDownloadDialogOpen
- IsSuspended
- Muted
Methods
- CloseDownloadDialog
- NavigateWithWebResourceRequestSync
- OpenDownloadDialog
- OpenTaskManagerWindow
Events
- OnDocumentPlayingAudioChanged
- OnDownloadDialogOpenChanged
- OnMutedChanged

New AntViewCookieManager interface
Methods
- AddOrUpdateCookie
- CopyCookie
- CreateCookie
- DeleteAllCookies
- DeleteCookie
- DeleteCookies
- DeleteCookiesWithDomainAndPath
- GetCookies
Events
- OnDestroy
- OnGetCookieList

New AntViewCookieList interface
Properties
- Count
Methods
- ValueAtIndex
Events
- OnDestroy

New AntViewCookie interface
Properties
- DefaultInterface
- domain
- Expires
- HttpOnly
- Secure
- IsSession
- Name
- path
- SameSite
- Value
Events
- OnDestroy

Bugfix/Changed behavior
- The online help system has been touched up a bit to work closer to how the Windows CHM help works and looks like.

For more information, including hyperlinked versions of the features above, please see our "News (https://antview.dev/news/)" page.

--
Wil

wila
31-Aug-2023, 08:11 AM
Hi,

There's another new release of AntView.

August 31, 2023

Release of version 1.1.314

New functionality:

AntView interface

Properties:
NextFocusWindowHandleHwnd
PreviousFocusWindowHandleHwnd
WebView2WindowHandle
WebView2WindowHandleHwnd
WindowHandle
WindowHandleHwnd

Methods:
CapturePreview

Events:
OnCapturePreviewCompleted

Extended the AntViewNewWindowRequestedEventArgs interface

Methods:
NewWindowDispatch

Available via: Download AntView version 1.1.314
(https://antview.dev/download/AntView-Setup-1.1.314.exe)
For more information, including hyperlinked versions of the features above, please see our "News (https://antview.dev/news/)" page.

--
Wil

wila
22-Nov-2023, 02:33 PM
Hi,

Another AntView release :)

November 22, 2023

Release of version 1.1.330

Fixed an issue with RequestFormSubmitById/RequestFormSubmitByName when used in a form that used the GET method.

New functionality:

AntView interface

Methods:


FocusNextObject
FocusPreviousObject


AntViewDocument interface

Methods:


SetElementAttributeById
SetElementAttributeByIdSync
SetElementAttributeByName
SetElementAttributeByNameSync


Events:


OnSetElementAttributeById
OnSetElementAttributeByName


Directly available via: Download AntView version 1.1.330 (https://antview.dev/download/AntView-Setup-1.1.330.exe)

For more information, including hyperlinked versions of the features above, please see our "News (https://antview.dev/news/)" page.

--
Wil

wila
22-Jan-2024, 10:06 AM
AntView has a new release, version 1.1.354

Improved the Document interface functionality by adding a lot of methods for direct access to html elements without needing the use of javascript.

More details at:
https://antview.dev/news/

Download at:
https://antview.dev/downloads/

--
Wil