FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour New Class TWebView in next FWH build
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 06:43 AM
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 !!! :-)

Code (fw): Select all Collapse
// Please install <!-- m --><a class="postlink" href="https://developer.microsoft.com/en-us/microsoft-edge/webview2/">https://developer.microsoft.com/en-us/m ... /webview2/</a><!-- m --> 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
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 08:02 AM

Can I run and get result embedded javascript?

line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 09:42 AM

Yes, it is properly working, in example:

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 10:49 AM
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.06
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 01:47 PM

Excelente Antonio, cuando estará disponible?

Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 02:06 PM
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
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 04:02 PM

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 25.01 ] [ xHarbour 64 bits) ]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New Class TWebView in next FWH build
Posted: Sat Jun 04, 2022 05:24 PM
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
Posts: 129
Joined: Mon Oct 17, 2005 03:03 AM
Re: New Class TWebView in next FWH build
Posted: Sun Jun 05, 2022 02:55 AM

great!

line ID: ssbbstw

WeChat ID: ssbbstw
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New Class TWebView in next FWH build
Posted: Mon Jun 06, 2022 07:50 AM
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 (fw): Select all Collapse
#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
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: New Class TWebView in next FWH build
Posted: Mon Jun 06, 2022 09:17 AM
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 (fw): Select all Collapse
#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.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New Class TWebView in next FWH build
Posted: Mon Jun 06, 2022 06:43 PM

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
Posts: 1286
Joined: Mon Feb 25, 2008 02:54 PM
Re: New Class TWebView in next FWH build
Posted: Tue Jun 07, 2022 02:34 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: New Class TWebView in next FWH build
Posted: Tue Jun 07, 2022 05:15 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: New Class TWebView in next FWH build
Posted: Tue Jun 07, 2022 05:48 PM

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.