New Class TWebView in next FWH build

New Class TWebView in next FWH build

Postby Antonio Linares » Sat Jun 04, 2022 6: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 !!! :-D

Code: Select all  Expand view  RUN
// 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
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New Class TWebView in next FWH build

Postby ssbbs » Sat Jun 04, 2022 8:02 am

Can I run and get result embedded javascript?
line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
ssbbs
 
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: New Class TWebView in next FWH build

Postby Antonio Linares » Sat Jun 04, 2022 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New Class TWebView in next FWH build

Postby Horizon » 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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New Class TWebView in next FWH build

Postby cmsoft » Sat Jun 04, 2022 1:47 pm

Excelente Antonio, cuando estará disponible?
User avatar
cmsoft
 
Posts: 1293
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: New Class TWebView in next FWH build

Postby ssbbs » Sat Jun 04, 2022 2: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
User avatar
ssbbs
 
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: New Class TWebView in next FWH build

Postby leandro » Sat Jun 04, 2022 4: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

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1676
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: New Class TWebView in next FWH build

Postby Antonio Linares » Sat Jun 04, 2022 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New Class TWebView in next FWH build

Postby ssbbs » Sun Jun 05, 2022 2:55 am

great!
line ID: ssbbstw
WeChat ID: ssbbstw
User avatar
ssbbs
 
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Re: New Class TWebView in next FWH build

Postby Antonio Linares » Mon Jun 06, 2022 7: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: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New Class TWebView in next FWH build

Postby Horizon » Mon Jun 06, 2022 9: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: Select all  Expand view  RUN
#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
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New Class TWebView in next FWH build

Postby Antonio Linares » Mon Jun 06, 2022 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New Class TWebView in next FWH build

Postby MGA » Tue Jun 07, 2022 2: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
MGA
 
Posts: 1253
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: New Class TWebView in next FWH build

Postby Antonio Linares » Tue Jun 07, 2022 5:15 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New Class TWebView in next FWH build

Postby Giovany Vecchi » Tue Jun 07, 2022 5: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.
User avatar
Giovany Vecchi
 
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests