Page 1 of 2
New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 6:43 am
by Antonio Linares
We have managed to create a new Class TWebView to use Microsoft Edge from FWH apps and the SAME source code works with Borland, Microsoft and MinGW and xHarbour too !!!

Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 8:02 am
by ssbbs
Can I run and get result embedded javascript?
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 9:42 am
by Antonio Linares
Yes, it is properly working, in example:
oWebView:Eval( 'document.body.style.backgroundColor = "#' + NumToHex( hb_Random( 0xFFFFFF ) ) + '"' )
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 10:49 am
by Horizon
Antonio Linares wrote:Yes, it is properly working, in example:
oWebView:Eval( 'document.body.style.backgroundColor = "#' + NumToHex( hb_Random( 0xFFFFFF ) ) + '"' )
waiting!.....
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 1:47 pm
by cmsoft
Excelente Antonio, cuando estará disponible?
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 2:06 pm
by ssbbs
Antonio Linares wrote:Yes, it is properly working, in example:
oWebView:Eval( 'document.body.style.backgroundColor = "#' + NumToHex( hb_Random( 0xFFFFFF ) ) + '"' )
How to get result?
ex: oWebView:Eval("return (1+2);")
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 4:02 pm
by leandro
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 5:24 pm
by Antonio Linares
ssbbs wrote:Antonio Linares wrote:Yes, it is properly working, in example:
oWebView:Eval( 'document.body.style.backgroundColor = "#' + NumToHex( hb_Random( 0xFFFFFF ) ) + '"' )
How to get result?
ex: oWebView:Eval("return (1+2);")
Basically this is the used technique:
oWebView:Bind( "SendToFWH", SendToFWH() ) // this creates a javascript function "SendToFWH" that will call FWH SendToFWH()
oWebView:Eval( "SendToFWH( 1 + 2 )" ) // this way we return a value from javascript to FWH
there is some C source code involved that we are working to simplify using the Class TWebView

Re: New Class TWebView in next FWH build
Posted: Sun Jun 05, 2022 2:55 am
by ssbbs
great!
Re: New Class TWebView in next FWH build
Posted: Mon Jun 06, 2022 7:50 am
by Antonio Linares
We managed to simplify all the required low level C code and see how nice and simple looks now:
You can use the "SendToFWH" name or any other name you may prefer

Code: Select all | Expand
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWebView := TWebView():New()
oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebView:Bind( "SendToFWH" )
oWebView:Navigate( Html() )
Sleep( 200 )
oWebView:Eval( "SendToFWH( 'ok' )" )
oWebView:Run()
oWebView:Destroy()
return nil
//----------------------------------------------------------------------------//
function Html()
local cHtml
TEXT INTO cHtml
data:text/html,
<html>
<head>
</head>
<body style="background-color:cyan">
<h2>Using WebView from FWH</h2>
<button onclick='SendToFWH( 123 )'>Call FWH app from web browser</button>
<button onclick='SendToFWH( 456 )'>Test 2</button>
<button onclick='SendToFWH( 123, 456, "yes it works!" )'>Test 3</button>
</body>
</html>
ENDTEXT
return cHtml
//----------------------------------------------------------------------------//
Re: New Class TWebView in next FWH build
Posted: Mon Jun 06, 2022 9:17 am
by Horizon
Antonio Linares wrote:We managed to simplify all the required low level C code and see how nice and simple looks now:
You can use the "SendToFWH" name or any other name you may prefer

Code: Select all | Expand
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWebView := TWebView():New()
oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebView:Bind( "SendToFWH" )
oWebView:Navigate( Html() )
Sleep( 200 )
oWebView:Eval( "SendToFWH( 'ok' )" )
oWebView:Run()
oWebView:Destroy()
return nil
//----------------------------------------------------------------------------//
function Html()
local cHtml
TEXT INTO cHtml
data:text/html,
<html>
<head>
</head>
<body style="background-color:cyan">
<h2>Using WebView from FWH</h2>
<button onclick='SendToFWH( 123 )'>Call FWH app from web browser</button>
<button onclick='SendToFWH( 456 )'>Test 2</button>
<button onclick='SendToFWH( 123, 456, "yes it works!" )'>Test 3</button>
</body>
</html>
ENDTEXT
return cHtml
//----------------------------------------------------------------------------//
Hi Antonio,
Can you give me an example that is read from an write to hmtl website.
When can we test this class?
Thanks.
Re: New Class TWebView in next FWH build
Posted: Mon Jun 06, 2022 6:43 pm
by Antonio Linares
Dear Hakan,
> Can you give me an example that is read from an write to hmtl website.
Not sure what you are asking exactly.
Using oWebView:Eval( cJavaScriptExpression ) you invoke javascript code from your FWH app and
you get the result using a codeblock oWebView:bOnBind. This is very powerful.
> When can we test this class?
We want to publish a FWH 22.06 asap
Re: New Class TWebView in next FWH build
Posted: Tue Jun 07, 2022 2:34 pm
by MGA
con la clase TWEBVIEW será posible volver a tener mapas (googlemaps) en diálogo (activeX)?
Re: New Class TWebView in next FWH build
Posted: Tue Jun 07, 2022 5:15 pm
by Antonio Linares
Re: New Class TWebView in next FWH build
Posted: Tue Jun 07, 2022 5:48 pm
by Giovany Vecchi
Very good Antonio.
I was taking a class too. I already had all the functions and I managed to work to run inside a resource or Window directly without having to capture the WebView window.
As I don't have time to improve the class, I'll wait for the native class for FiveWin.