FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Utilities / Utilidades WebView2 for Harbour/Fivewin and VSC 2019
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
WebView2 for Harbour/Fivewin and VSC 2019
Posted: Tue Sep 21, 2021 10:38 AM
Bienvenido a FE_WebView2 ( version preliminar )
He incluido un ejemplo de uso del control para ser usado desde aplicaciones Fivewin.
Al principio del ejemplo, he detallado algunas de las webs en las que he basado mi trabajo o que he considerado interesante para las personas que quieran profundizar en este tema.
Este control WebView2 se puede desarrollar utilizando C o C++
Tambi茅n estoy trabajando desde hace tiempo en otra versi贸n que utiliza C++.
Incluyo las librer铆as que son necesarias linkar para poder utilizarlo
S贸lo est谩n inclu铆das las librer铆as para VSC 2019 32 bits.
Se han utilizado las caracter铆sticas que os pueden ser m谩s pr谩cticas.
Considero que el ejemplo es, por s铆 mismo, suficientemente explicativo, pero, cualquier duda o sugerencia, he considerado, que, en lugar de hacer un "manual", ser谩 mejor ir comentando en el foro.
He incluido el programa de instalaci贸n de Microsoft para que puedas utilizar este control en tu ordenador.

Espero que os guste

English
---------

Welcome to FE_WebView2 (preview version)
I have included an example of the use of the control to be used from Fivewin applications.
At the beginning of the example, I have detailed some of the websites on which I have based my work or that I have considered interesting for people who want to delve into this topic.
This WebView2 control can be developed using C or C ++
I am also working for a long time on another version that uses C ++.
I include the libraries that are necessary to link to be able to use it
Only the libraries for VSC 2019 32 bits are included.
The characteristics that can be more practical have been used.
I consider that the example is, by itself, sufficiently explanatory, but, any doubt or suggestion, I have considered that, instead of making a "manual", it will be better to comment on the forum.
I have included the Microsoft installation program so that you can use this control on your computer.

I hope you like it

Download:
https://bitbucket.org/fivetech/fivewin-contributions/downloads/FEWebViewC.zip

METHODS and DATAs
Code (fw): Select all Collapse
//----------------------------------------------------------------------------//
//  Author  :    Cristobal Navarro Lopez ( c )
//  CLASS   :    TWEBVIEWC
//  Date    :    18/09/2021
//  Version :    0.0918      BETA
//  
//----------------------------------------------------------------------------//
#include "Fivewin.ch"

CLASS TWebViewC

   DATA cVersion      INIT ""
   DATA hWnd
   DATA cUrl          INIT ""
   DATA cUrlInit      INIT "about:blank"
   DATA lMenuPop      INIT .T.
   DATA lToolsDev     INIT .T.
   

   METHOD New( oParent, cUrl ) CONSTRUCTOR
   METHOD Activate()
   METHOD Close()
   METHOD EnableDevTools( lDevTools )
   METHOD EnablePopupMnu( lPopMnu )
   METHOD End()
   METHOD ExecuteScript( cScript )
   METHOD ExecuteScriptOnCreate( cScript )
   METHOD GoBack()
   METHOD GoForward()
   METHOD HWndWebView()
   METHOD Init( lInit )
   METHOD Navigate( cUrl )
   METHOD Reload()
   METHOD ResizeWebView()
   METHOD ShowHtml( cHtml )
   METHOD Stop()
   METHOD Url( cUrl )
   METHOD Version()

ENDCLASS

//----------------------------------------------------------------------------//
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Tue Sep 21, 2021 11:13 AM

Espectacular Cristobal!
Muchas gracias!

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Tue Sep 21, 2021 02:03 PM

Felicitaciones Crist贸bal, muy buen trabajo.

Por un momento alcance a pensar que podr铆amos ejecutar una funci贸n de fw desde del navegador :shock: , me lograste confundir con el panel de superior derecho.

De nuevo felicitaciones, ahora el tema de mi parte pasar por lograr compilar la aplicaci贸n con las herramientas MVSC.

De nuevo gracias :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: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Tue Sep 21, 2021 02:09 PM

Leandro
Es una version preliminar
El tema de enviar mensajes entre WebView <--> Fw ser谩 la segunda versi贸n
Enviar mensajes al Webview desde Fw est谩 hecho ( al margen de ejecutar javascript, que son dos temas distintos aunque se pueden confundir )
Enviar mensajes desde el webview a la ventana / contenedor de fw estoy con ello ya que seguramente haya que modificar alguna cosilla en Fw.
Ya ir茅 informando.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Tue Sep 21, 2021 07:52 PM

Thank you Mr. Navarro,

First, We can open website such as "http://forums.fivetechsupport.com/".

I think we should click the Login button, and enter username and password.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Tue Sep 21, 2021 09:58 PM

Dear Hakan
What you are commenting on is perfectly possible.
I have put the side panels made with Fivewin to use in the later versions that I will publish.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Wed Sep 22, 2021 07:57 AM
cnavarro wrote:Dear Hakan
What you are commenting on is perfectly possible.
I have put the side panels made with Fivewin to use in the later versions that I will publish.


I think we should find the elementName that we will interact to variable.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Wed Sep 22, 2021 10:34 AM
Horizon wrote:
cnavarro wrote:Dear Hakan
What you are commenting on is perfectly possible.
I have put the side panels made with Fivewin to use in the later versions that I will publish.


I think we should find the elementName that we will interact to variable.


I am sorry, I do not understand
It is different from sending javascript code from Fw to be executed in the Webview, than sending messages from the Fw window / container to the Webview window.
Can you explain your comment better?
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Wed Sep 22, 2021 12:00 PM

Hi, Mr. Navarro,

I tought old IE way like DOM Element.

For example.

We open the "http://forums.fivetechsupport.com/" link. (I assume that this site is not mine control)
We want to double click "Login" to enter login username and password.

How can I find the login element and simulates double-click? This is I meant.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Fri Sep 24, 2021 01:41 PM

Hi Mr. Navarro,

Any progress?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Tue Sep 28, 2021 08:31 AM
Excuse me, but I didn't understand that you were asking me a question.
The issue you raise is not a problem with the webview and its capabilities, but with your knowledge of javascript.
You should use the browser's inspector and view the source code of the page. Once you have the 'id' of the button, or of the element that you want to use, it is as simple as executing the corresponding javascript commands from your code

Code (fw): Select all Collapse
// id of button is "btt1"
oWeb:ExecuteScript( 'document.getElementById( "btt1" ).focus();' + ;
                                'document.getElementById( "btt1" ).click()' ) )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Wed Sep 29, 2021 07:22 AM
Thank you Mr. Navarro,

I am also newby of javascript. I want to start somewhere. Can you help me to focus a get element and enter something to it.

My link is "https://vatandas.uyap.gov.tr/main/vatandas/giris.jsp". I clicked "E-艦ifre Arac谋l谋臒谋yla Giri艧" button as you describe. but I can not focus and enter something
to the "T.C. Kimlik No" get element.

My code is below.

Code (fw): Select all Collapse
PROCEDURE Main()
聽 local oWnd, oWeb, cLink, oWnw
聽 聽 cLink := "https://vatandas.uyap.gov.tr/main/vatandas/giris.jsp"
聽 聽 
聽 聽DEFINE WINDOW oWnd TITLE "FiveWin" ;
聽 聽 聽 FROM 3, 1050 TO 750, 1550 PIXEL

聽 聽DEFINE MESSAGE BAR OF oWnd PROMPT FWVERSION + " " + FWCOPYRIGHT // Strings defined
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// inside FiveWin.ch
聽 聽ACTIVATE WINDOW oWnd ;
聽 聽 聽 ON INIT ONINIT_Girisi( oWnd, cLink, @oWeb ) ;
聽 聽 聽 ON RESIZE ( if( Valtype( oWeb ) = "O", oWeb:ResizeWebView(), ) ) ;
聽 聽 聽 VALID ( if( Valtype( oWeb ) = "O", oWeb:End(), ), .T. )

RETURN 聽 聽 

PROCEDURE ONINIT_Girisi(oWnd, cLink, oWeb)
聽 聽 oWeb := TWebViewC():New( oWnd:hWnd, cLink )
聽 IF Empty( oWeb:Version())
聽 聽 聽 聽 MsgStop( "No installed runtime of webview2 was detected", "WebView2 Error" )
聽 聽 聽 聽 oWindow:End()
聽 聽 ELSE
聽 聽 聽 聽 oWeb:Activate()
聽 聽 聽 聽 oWeb:EnableDevTools()
聽 聽 聽 聽 
聽 聽 聽 聽 cTCNo := "12345678901"
聽 聽 聽 聽 cPass := "2222"

聽 聽 聽 聽 SysWait(2)聽 聽 聽 聽 聽 聽 聽 // This is a temporary solution. I must check the idle. like .. Do While IE:Busy
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //聽 聽 聽 聽 聽 聽 聽SysWait(1)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //聽 聽 聽 聽 聽 聽 聽SysRefresh() // To Refresh
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //聽 聽 聽 聽 聽 聽 聽Loop
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //聽 聽 聽 聽 聽 Enddo
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 
聽 聽 聽 聽 oWeb:ExecuteScript( 'document.getElementsByClassName( "btn red-flamingo" )[0].focus();' + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 'document.getElementsByClassName( "btn red-flamingo" )[0].click();')
聽 聽 聽 
聽 聽 聽 聽 SysWait(2)
聽 聽 聽 聽 oWeb:ExecuteScript( 'document.getElementById( "tridField" ).focus();' + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 'document.getElementById( "tridField" ).textContent = '+cTCNo+'' ) 聽聽 聽 聽 聽 

聽 聽 聽 聽 
聽 聽 ENDIF
RETURN
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Wed Sep 29, 2021 07:22 AM

double. sorry.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Wed Sep 29, 2021 12:33 PM
you can also directly execute the action that the button has
Code (fw): Select all Collapse
oWeb:ExecuteScript( "location.href=Application.getEDevletESifreEntryURL();")
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: WebView2 for Harbour/Fivewin and VSC 2019
Posted: Wed Sep 29, 2021 12:46 PM
Thank you Mr. Navarro,

What about this code.
Code (fw): Select all Collapse
        oWeb:ExecuteScript( 'document.getElementById( "tridField" ).focus();' + ;
                        'document.getElementById( "tridField" ).textContent = '+cTCNo+'' )
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06