New Class TWebView in next FWH build

User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

New Class TWebView in next FWH build

Post 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 !!! :-D

Code: Select all | Expand

// Please install https://developer.microsoft.com/en-us/m ... /webview2/ x86 version before using it

#include "FiveWin.ch"

function Main()

   local oWebView := TWebView():New()

   oWebView:Navigate( "http://www.google.com" )
   oWebView:Run()
   oWebView:Destroy()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
ssbbs
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: New Class TWebView in next FWH build

Post by ssbbs »

Can I run and get result embedded javascript?
line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: New Class TWebView in next FWH build

Post by Antonio Linares »

Yes, it is properly working, in example:

oWebView:Eval( 'document.body.style.backgroundColor = "#' + NumToHex( hb_Random( 0xFFFFFF ) ) + '"' )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Horizon
Posts: 1327
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 5 times

Re: New Class TWebView in next FWH build

Post by Horizon »

Antonio Linares wrote:Yes, it is properly working, in example:

oWebView:Eval( 'document.body.style.backgroundColor = "#' + NumToHex( hb_Random( 0xFFFFFF ) ) + '"' )


waiting!.....
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
User avatar
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

Re: New Class TWebView in next FWH build

Post by cmsoft »

Excelente Antonio, cuando estará disponible?
User avatar
ssbbs
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: New Class TWebView in next FWH build

Post 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);")
line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
leandro
Posts: 1770
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Has thanked: 49 times
Been thanked: 12 times
Contact:

Re: New Class TWebView in next FWH build

Post by leandro »

Que buena noticia :D :D :D :D :D
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 24.09 ] [ xHarbour 64 bits) ]
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: New Class TWebView in next FWH build

Post 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 :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
ssbbs
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: New Class TWebView in next FWH build

Post by ssbbs »

great!
line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: New Class TWebView in next FWH build

Post 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

//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com
Horizon
Posts: 1327
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 5 times

Re: New Class TWebView in next FWH build

Post 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.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: New Class TWebView in next FWH build

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
MGA
Posts: 1258
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

Re: New Class TWebView in next FWH build

Post by MGA »

con la clase TWEBVIEW será posible volver a tener mapas (googlemaps) en diálogo (activeX)?
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: New Class TWebView in next FWH build

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: New Class TWebView in next FWH build

Post 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.
Post Reply