FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TWebView:Destroy method does not close the window.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 05:31 AM

Dear Hakan,

If that example is fine for you, ok. To me, the MDI environment is the right one to have multiple webviews running at the same time

Estimado César,

Si estás interesado en probar los últimos cambio, te envío las librerias. De momento solo se las he enviado a Hakan por que él está
muy activo probando webview :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 12:50 PM

Si no es molestia, me gustaría probarlas...
Muchas gracias Antonio

Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 12:51 PM
Antonio Linares wrote:Dear Hakan,
If that example is fine for you, ok. To me, the MDI environment is the right one to have multiple webviews running at the same time

Igual para mi!
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 01:12 PM
Hi Antonio,

I have two version of TWebView examples that shows both "document.readyState"

First one is original FWH TWebView class with dialog container with your last sended fwh libs.
Code (fw): Select all Collapse
#include "FiveWin.ch"
function Main()
  local oWnd, oBar

   DEFINE WINDOW oWnd 

   DEFINE BUTTONBAR oBar 3D OF oWnd SIZE 60, 60

   DEFINE BUTTON PROMPT "Open" OF oBar ACTION (Open_Google( oWnd ))

   ACTIVATE WINDOW oWnd

return nil

function Open_Google( oWnd )
LOCAL cHtml:="https://forums.fivetechsupport.com/ucp.php?mode=login&sid=12267e643672303281cdf64289c6875d"
local oWndChild, oWebView


  DEFINE WINDOW oWndChild TITLE "My Test FW Window_"+TIME() ;
    FROM 100, 100 TO 768, 1024 PIXEL

  oWndChild:bInit := <||
        oWebView := TWebView():New(,oWndChild:hWnd)
        oWebView:SetSize(oWndChild:nWidth, oWndChild:nHeight,0)
        oWebView:bOnBind = { | cJson, nCalls |  GetDataFrom_WebView( cJson, nCalls ) }
        oWebView:Bind( "SendToFWH" )       
        oWebView:Navigate(cHtml)
//      oWebView:Run()                              // We dont need when oWndChild
     Return Nil
  >
 
    oWndChild:bValid := <||
       oWebView:Destroy()
       Return .T. 
    >
    
  ACTIVATE WINDOW oWndChild
    
  ? "I am here - Outside"


        cMyParam := "" 
        cText := 'document.readyState'
        oWebView:Eval("SendToFWH( "+cText+")")  
        SysWait(2)
        ? cMyParam, "cMyParam - readyState'"
        
    
return nil

PROCEDURE GetDataFrom_WebView(cJson, nCalls)
    cMyParam := cJson
RETURN



Second one uses TOB_WebView class derived from original FWH TWebView class. It has only one method. (new method). It is exactly does same thing.
Code (fw): Select all Collapse
#include "FiveWin.ch"
function Main()
  local oWnd, oBar

   DEFINE WINDOW oWnd 

   DEFINE BUTTONBAR oBar 3D OF oWnd SIZE 60, 60

   DEFINE BUTTON PROMPT "Open" OF oBar ACTION (Open_Google( oWnd ))

   ACTIVATE WINDOW oWnd

return nil

function Open_Google( oWnd )
LOCAL cHtml:="https://forums.fivetechsupport.com/ucp.php?mode=login&sid=12267e643672303281cdf64289c6875d"
local oWndChild, oWebView


  DEFINE WINDOW oWndChild TITLE "My Test FW Window_"+TIME() ;
    FROM 100, 100 TO 768, 1024 PIXEL

  oWndChild:bInit := <||
        oWebView := TOB_WebView():New(oWndChild)
        oWebView:bOnBind = { | cJson, nCalls |  GetDataFrom_WebView( cJson, nCalls ) }
        oWebView:Bind( "SendToFWH" )       
        oWebView:Navigate(cHtml)
//      oWebView:Run()                              // We dont need when oWndChild
     Return Nil
  >
 
    oWndChild:bValid := <||
       oWebView:Destroy()
       Return .T. 
    >
    
  ACTIVATE WINDOW oWndChild
    
  ? "I am here - Outside"


        cMyParam := "" 
        cText := 'document.readyState'
        oWebView:Eval("SendToFWH( "+cText+")")  
        SysWait(2)
        ? cMyParam, "cMyParam - readyState'"
        
    
return nil

PROCEDURE GetDataFrom_WebView(cJson, nCalls)
    cMyParam := cJson
RETURN
*------------------------------------------------------------------------------------------
CLASS TOB_WebView FROM TWebView
    Data oWndDlgContainer
    DATA lStartRun INIT .F.
    
    METHOD New(oWndDlgContainer) Constructor

    
ENDCLASS

METHOD New(oWndDlgContainer) CLASS TOB_WebView
Local lc_lLoopReSize := .F.
  ::oWndDlgContainer := oWndDlgContainer

   If !Hb_IsNil(::oWndDlgContainer)
      ::hWebView        := WEBVIEW_CREATE(,::oWndDlgContainer:hWnd)
      ::oWndDlgContainer:bResized := <||
         If !lc_lLoopReSize 
            lc_lLoopReSize := .T.
            hb_idleSleep(.001)
            ::SetSize(::oWndDlgContainer:nWidth,;
                                          ::oWndDlgContainer:nHeight,0)
            lc_lLoopReSize := .F.
         EndIf
         Return Nil
      > 
   Else 
      ::hWebView        := WEBVIEW_CREATE()
   EndIf  
  
RETURN Self


Problem is that first example show ["complete"]. This is exactly the expected data.
But second one there is not any read data even both example runs original Eval Method from FWH TWebView class, because there is not any derived Eval function. I gues

Can you help me please?
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 02:07 PM
Horizon wrote:
Second one uses TOB_WebView class derived from original FWH TWebView class. It has only one method. (new method). It is exactly does same thing.
Code (fw): Select all Collapse
#include "FiveWin.ch"
function Main()
  local oWnd, oBar

   DEFINE WINDOW oWnd 

   DEFINE BUTTONBAR oBar 3D OF oWnd SIZE 60, 60

   DEFINE BUTTON PROMPT "Open" OF oBar ACTION (Open_Google( oWnd ))

   ACTIVATE WINDOW oWnd

return nil

function Open_Google( oWnd )
LOCAL cHtml:="https://forums.fivetechsupport.com/ucp.php?mode=login&sid=12267e643672303281cdf64289c6875d"
local oWndChild, oWebView


  DEFINE WINDOW oWndChild TITLE "My Test FW Window_"+TIME() ;
    FROM 100, 100 TO 768, 1024 PIXEL

  oWndChild:bInit := <||
        oWebView := TOB_WebView():New(oWndChild)
        oWebView:bOnBind = { | cJson, nCalls |  GetDataFrom_WebView( cJson, nCalls ) }
        oWebView:Bind( "SendToFWH" )       
        oWebView:Navigate(cHtml)
//      oWebView:Run()                              // We dont need when oWndChild
     Return Nil
  >
 
    oWndChild:bValid := <||
       oWebView:Destroy()
       Return .T. 
    >
    
  ACTIVATE WINDOW oWndChild
    
  ? "I am here - Outside"


        cMyParam := "" 
        cText := 'document.readyState'
        oWebView:Eval("SendToFWH( "+cText+")")  
        SysWait(2)
        ? cMyParam, "cMyParam - readyState'"
        
    
return nil

PROCEDURE GetDataFrom_WebView(cJson, nCalls)
    cMyParam := cJson
RETURN
*------------------------------------------------------------------------------------------
CLASS TOB_WebView FROM TWebView
    Data oWndDlgContainer
    DATA lStartRun INIT .F.
    
    METHOD New(oWndDlgContainer) Constructor

    
ENDCLASS

METHOD New(oWndDlgContainer) CLASS TOB_WebView
Local lc_lLoopReSize := .F.
  ::oWndDlgContainer := oWndDlgContainer

   If !Hb_IsNil(::oWndDlgContainer)
      ::hWebView        := WEBVIEW_CREATE(,::oWndDlgContainer:hWnd)
      ::oWndDlgContainer:bResized := <||
         If !lc_lLoopReSize 
            lc_lLoopReSize := .T.
            hb_idleSleep(.001)
            ::SetSize(::oWndDlgContainer:nWidth,;
                                          ::oWndDlgContainer:nHeight,0)
            lc_lLoopReSize := .F.
         EndIf
         Return Nil
      > 
   Else 
      ::hWebView        := WEBVIEW_CREATE()
   EndIf  
  
RETURN Self

Problem is that first example show ["complete"]. This is exactly the expected data.
But second one there is not any read data even both example runs original Eval Method from FWH TWebView class, because there is not any derived Eval function. I gues

Can you help me please?


Hello, this code is from a class I was building. I posted it here just so it could be analyzed. The correct thing is you use the class that Linares is building. In the future I will also use the native fivewin class.

Here are the sources:
https://app.box.com/s/dklixp7uu9ni5sz8llqt3nq1zqp13kyb
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 02:11 PM
Giovany Vecchi wrote:
Horizon wrote:
Second one uses TOB_WebView class derived from original FWH TWebView class. It has only one method. (new method). It is exactly does same thing.
Code (fw): Select all Collapse
#include "FiveWin.ch"
function Main()
  local oWnd, oBar

   DEFINE WINDOW oWnd 

   DEFINE BUTTONBAR oBar 3D OF oWnd SIZE 60, 60

   DEFINE BUTTON PROMPT "Open" OF oBar ACTION (Open_Google( oWnd ))

   ACTIVATE WINDOW oWnd

return nil

function Open_Google( oWnd )
LOCAL cHtml:="https://forums.fivetechsupport.com/ucp.php?mode=login&sid=12267e643672303281cdf64289c6875d"
local oWndChild, oWebView


  DEFINE WINDOW oWndChild TITLE "My Test FW Window_"+TIME() ;
    FROM 100, 100 TO 768, 1024 PIXEL

  oWndChild:bInit := <||
        oWebView := TOB_WebView():New(oWndChild)
        oWebView:bOnBind = { | cJson, nCalls |  GetDataFrom_WebView( cJson, nCalls ) }
        oWebView:Bind( "SendToFWH" )       
        oWebView:Navigate(cHtml)
//      oWebView:Run()                              // We dont need when oWndChild
     Return Nil
  >
 
    oWndChild:bValid := <||
       oWebView:Destroy()
       Return .T. 
    >
    
  ACTIVATE WINDOW oWndChild
    
  ? "I am here - Outside"


        cMyParam := "" 
        cText := 'document.readyState'
        oWebView:Eval("SendToFWH( "+cText+")")  
        SysWait(2)
        ? cMyParam, "cMyParam - readyState'"
        
    
return nil

PROCEDURE GetDataFrom_WebView(cJson, nCalls)
    cMyParam := cJson
RETURN
*------------------------------------------------------------------------------------------
CLASS TOB_WebView FROM TWebView
    Data oWndDlgContainer
    DATA lStartRun INIT .F.
    
    METHOD New(oWndDlgContainer) Constructor

    
ENDCLASS

METHOD New(oWndDlgContainer) CLASS TOB_WebView
Local lc_lLoopReSize := .F.
  ::oWndDlgContainer := oWndDlgContainer

   If !Hb_IsNil(::oWndDlgContainer)
      ::hWebView        := WEBVIEW_CREATE(,::oWndDlgContainer:hWnd)
      ::oWndDlgContainer:bResized := <||
         If !lc_lLoopReSize 
            lc_lLoopReSize := .T.
            hb_idleSleep(.001)
            ::SetSize(::oWndDlgContainer:nWidth,;
                                          ::oWndDlgContainer:nHeight,0)
            lc_lLoopReSize := .F.
         EndIf
         Return Nil
      > 
   Else 
      ::hWebView        := WEBVIEW_CREATE()
   EndIf  
  
RETURN Self

Problem is that first example show ["complete"]. This is exactly the expected data.
But second one there is not any read data even both example runs original Eval Method from FWH TWebView class, because there is not any derived Eval function. I gues

Can you help me please?


Hello, this code is from a class I was building. I posted it here just so it could be analyzed. The correct thing is you use the class that Linares is building. In the future I will also use the native fivewin class.

Here are the sources:
https://app.box.com/s/dklixp7uu9ni5sz8llqt3nq1zqp13kyb


Yes Giavony, you are right. Much obliged. I just want to give this example to compare. What is different?
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 03:14 PM
Horizon wrote:
Yes Giavony, you are right. Much obliged. I just want to give this example to compare. What is different?


I don't know what the difference is because I don't have the 2206 version of fivewin. I'm using version 1909.
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: TWebView:Destroy method does not close the window.
Posted: Fri Aug 05, 2022 08:19 PM

Hi Antonio,

Can you help me please?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: TWebView:Destroy method does not close the window.
Posted: Sat Aug 06, 2022 09:53 AM
Hi Antonio,

I found my mistake.

I used the WebView_Create function in the New method of my own class. So my class does not added to aWebView array that is used for to run Bind function.

I have changed CREATE_WEBVIEW() functions to ::New(....). Sorry for making you unnecessarily busy.

This is full working my second example (Created with the idea taken from Giovany's examples.)
Code (fw): Select all Collapse
#include "FiveWin.ch"
function Main()
  local oWnd, oBar

   DEFINE WINDOW oWnd 

   DEFINE BUTTONBAR oBar 3D OF oWnd SIZE 60, 60

   DEFINE BUTTON PROMPT "Open" OF oBar ACTION (Open_Google( oWnd ))

   ACTIVATE WINDOW oWnd

return nil

function Open_Google( oWnd )
LOCAL cHtml:="https://forums.fivetechsupport.com/ucp.php?mode=login&sid=12267e643672303281cdf64289c6875d"
local oWndChild, oWebView


  DEFINE WINDOW oWndChild TITLE "My Test FW Window_"+TIME() ;
    FROM 100, 100 TO 768, 1024 PIXEL

  oWndChild:bInit := <||
//      oWebView := TWebView():New(,oWndChild:hWnd)
//      oWebView:SetSize(oWndChild:nWidth, oWndChild:nHeight,0)

        oWebView := TOB_WebView():New(oWndChild)

            oWebView:bOnBind = { | cJson, nCalls |  GetDataFrom_WebView( cJson, nCalls ) }
            oWebView:Bind( "SendToFWH" )       
        oWebView:Navigate(cHtml)
//      oWebView:Run()                              // We dont need when oWndChild
     Return Nil
  >
 
    oWndChild:bValid := <||
       oWebView:Destroy()
       Return .T. 
    >
    
  ACTIVATE WINDOW oWndChild
    
  ? "I am here - Outside"


        cMyParam := "" 
        cText := 'document.readyState'
        oWebView:Eval("SendToFWH( "+cText+")")  
        SysWait(2)
        ? cMyParam, "cMyParam - readyState'"
        
    
return nil

PROCEDURE GetDataFrom_WebView(cJson, nCalls)
    cMyParam := cJson
RETURN
*------------------------------------------------------------------------------------------
CLASS TOB_WebView FROM TWebView
    Data oWndDlgContainer
    DATA lStartRun INIT .F.
    
    METHOD New(oWndDlgContainer) Constructor

    
ENDCLASS

METHOD New(oWndDlgContainer) CLASS TOB_WebView
Local lc_lLoopReSize := .F.
  ::oWndDlgContainer := oWndDlgContainer

   If !Hb_IsNil(::oWndDlgContainer)
//      ::hWebView        := WEBVIEW_CREATE(,::oWndDlgContainer:hWnd)   
            ::Super:New(,::oWndDlgContainer:hWnd)  // Changed
      ::oWndDlgContainer:bResized := <||
         If !lc_lLoopReSize 
            lc_lLoopReSize := .T.
            hb_idleSleep(.001)
            ::SetSize(::oWndDlgContainer:nWidth,;
                                          ::oWndDlgContainer:nHeight,0)
            lc_lLoopReSize := .F.
         EndIf
         Return Nil
      > 
   Else 
            ::Super:New()           // Changed
//      ::hWebView        := WEBVIEW_CREATE()
   EndIf  
  
RETURN Self
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TWebView:Destroy method does not close the window.
Posted: Sat Aug 06, 2022 04:50 PM
cmsoft wrote:Si no es molestia, me gustaría probarlas...
Muchas gracias Antonio


Estimado César,

Para que compilador de C las necesitas ?

saludos
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: TWebView:Destroy method does not close the window.
Posted: Sat Aug 06, 2022 07:32 PM

BCC7

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TWebView:Destroy method does not close the window.
Posted: Sun Aug 07, 2022 05:31 AM

Enviadas! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: TWebView:Destroy method does not close the window.
Posted: Sun Aug 07, 2022 06:57 AM

Dear Antonio,
What exactly do I need to download to test the TWebview examples out of the box.

Does it also work with xHarbour?

Best regards,
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TWebView:Destroy method does not close the window.
Posted: Sun Aug 07, 2022 09:52 AM

Dear Otto,

> What exactly do I need to download to test the TWebview examples out of the box.

Simply install FWH 22.06 then go to samples folder and do:
buildh webview
buildh webviewuni

> Does it also work with xHarbour?

Yes, 100% fully supported :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: TWebView:Destroy method does not close the window.
Posted: Sun Aug 07, 2022 10:00 AM

Dear Antonio,
thank you so much and have a nice Sunday.
Best regards,
Otto