Page 8 of 13
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Sat Dec 10, 2022 9:21 pm
by infratec
Updated the listing above:
added a lot of new features.
But for this it was also necesarry to extend WebView2.pbi.
I addede the additional code alo in the posting above.
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Mon Dec 12, 2022 3:59 pm
by infratec
Updated the listing above:
added a lot of new events and procedures.
After the alert appears, open the menu and download one of the demo files.
You will see download events in the Debug window.
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Mon Dec 12, 2022 5:23 pm
by vmars316
Thanks infratec ,
What do I need to bring KidSafafeBrowser up to date , just gdiplus ?
Thanks
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Mon Dec 12, 2022 5:30 pm
by infratec
vmars316 wrote: Mon Dec 12, 2022 5:23 pm
What do I need to bring KidSafafeBrowser up to date , just gdiplus ?
I have no idea from what you are talking.
I created a WebView2 Gadget as a replacement for the outdated WebGadget().
Inside you can open web pages, but not browsers.
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Mon Dec 12, 2022 6:05 pm
by vmars316
infratec wrote: Mon Dec 12, 2022 5:30 pm
vmars316 wrote: Mon Dec 12, 2022 5:23 pm
What do I need to bring KidSafafeBrowser up to date , just gdiplus ?
I have no idea from what you are talking.
I created a WebView2 Gadget as a replacement for the outdated WebGadget().
Inside you can open web pages, but not browsers.
From the recent activity above
I am thinking that I may need to re-download "Webview2 control - Chromium browser for Purebasic (Windows)"
to keep up-to-date .
Thanks
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Mon Dec 12, 2022 6:55 pm
by infratec
To run my WebView2Gadget()
You need the original stuff from justin:
https://github.com/omegakode/PBWebview2
You need to add the extensions to webvie2.pbi
And if the original loader creates a warning about unresolved externals, you need also the version which I provided as first listing.
Then place the WebView2gadget.pbi in same folder and copy the required loader dll (x86 or x64) in the same directory.
After this the demo inside WebView2Gadget.pbi should work.
Many work, but I don't want to steal the work of justin, since my work is only an addition to his work.
If the WebView2 runtime is not installed you need also to install it from here:
https://go.microsoft.com/fwlink/p/?LinkId=2124703
But on many Win10 PCs it is already available and on Win11 it is definately installed.
Re: Webview2 control - Chromium browser for Purebasic (Windo
Posted: Thu Dec 15, 2022 3:11 pm
by Joubarbe
Fred wrote: Mon Sep 14, 2020 8:39 am
Finally a new native solution is coming ! Thanks for the wrapper, we will look into it once it gets live.
Is there a native solution?
Re: Webview2 control - Chromium browser for Purebasic (Windo
Posted: Thu Dec 15, 2022 3:29 pm
by Kiffi
Joubarbe wrote: Thu Dec 15, 2022 3:11 pmFred wrote: Mon Sep 14, 2020 8:39 amFinally a new native solution is coming ! Thanks for the wrapper, we will look into it once it gets live.
Is there a native solution?
It's about time:
Internet Explorer 11 desktop app retirement FAQ 
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Thu Dec 15, 2022 6:08 pm
by Joubarbe
Hmm? Sorry I think I misunderstood the comment of Fred; thought the Web Gadget of PB was going to become a Chromium control, "natively". It's a bit cringy to still read in 2022: "The WebGadget uses the Internet Explorer 4.0+ ActiveX object on Windows. ".
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Thu Dec 15, 2022 6:25 pm
by plouf
not accurate
WebGadget uses ie and can be configured up to the latest ie11 emulation (i.e full IE11) by setting properly registry
Code: Select all
Procedure SetBrowserFeatureControl(rpath.s, dwValue.i)
dwLabel.s = GetFilePart(ProgramFilename())
RegCreateKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\"+ rPath.s, 0, #Null, #REG_OPTION_VOLATILE, #KEY_ALL_ACCESS, #Null, @phkResult, @Disposition)
RegSetValueEx_(phkResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long))
EndProcedure
SetBrowserFeatureControl("FEATURE_BROWSER_EMULATION", 11001) ;; enable IE11 rendering
even when WebGadget2() becomes native using native webview2 by microsoft (chromium/edge)
WebGadget() WILL and SHOULD remain, because of very high dependency of active components in a numerous commercial products out there need this
offcourse all new design should focus in html5 but compatibility should be needed for decades...
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Thu Dec 15, 2022 7:37 pm
by Kiffi
For example, you could use something like this
Code: Select all
UseWebGadget([WebView2LoaderLibraryName$])
similar to UseSQLiteDatabase() or
Code: Select all
InitWebGadget([WebView2LoaderLibraryName$])
similar to InitScintilla()
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Fri Dec 16, 2022 12:44 pm
by Caronte3D
plouf wrote: Thu Dec 15, 2022 6:25 pm
not accurate
WebGadget uses ie and can be configured up to the latest ie11 emulation (i.e full IE11) by setting properly registry...
Wow!

I don't know about it, thanks for sharing

Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Wed Jan 11, 2023 7:42 am
by Oliver13
First I want to thank Justin and infratec for the great work !
@infratec: there seem to be a strange bug in the WebView2 gadget replacement.
Calling WebView2SetGadgetText results in an IMA
To reproduce, please modify the
sample code
Code: Select all
OpenWindow(0, 0, 0, 1230, 820, "WebView2 Gadget", #PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)
WebView2Gadget(1, 10, 10, 600, 800, "https://www.purebasic.fr/english")
WebView2Gadget(2, 620, 10, 600, 800, "https://www.purebasic.fr/german")
WebView2SetGadgetText(1,"https://www.purebasic.fr/english"); <--- adding this line leads to an IMA
IMA occurs in
Code: Select all
Procedure WebView2SetgadgetText(Gadget.i, URL$)
[..]
*Gadget\wvCore\Navigate(URL$) ; <------ here the IMA occurs
[..]
EndProcedure
Do you have any idea ? Tested with X86 code
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Wed Jan 11, 2023 2:08 pm
by infratec
The problem is ... you are to fast.
The WebView2 from MS takes a bit time to load and initialize.
This is done in a thread.
You can see this, because the error comes before you can see:
Debug "Webview2Controller_Created"
I can implement a flag which is set when everything is finished.
But then you still have to wait for that flag.
Or I secure it, but then your command is not executed and I return a #False.
I test now how long it blocks if I wait until the WebView2Gadget() is completely working.
Re: Webview2 control - Chromium browser for Purebasic (Windows)
Posted: Wed Jan 11, 2023 2:25 pm
by infratec
I can only fix it if I add this add the end of the WebView2Gadget():
Code: Select all
Repeat
WindowEvent()
Delay(10)
Until WebView2GadgetMap()\InitDone
InitDone is set to #True at the end of Webview2Controller_Created()
But I don't want to do this, because I maybe loose some Events.