TWebView:Destroy method does not close the window.

Re: TWebView:Destroy method does not close the window.

Postby Antonio Linares » Fri Aug 05, 2022 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TWebView:Destroy method does not close the window.

Postby cmsoft » Fri Aug 05, 2022 12:50 pm

Si no es molestia, me gustaría probarlas...
Muchas gracias Antonio
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: TWebView:Destroy method does not close the window.

Postby cmsoft » 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!
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: TWebView:Destroy method does not close the window.

Postby Horizon » Fri Aug 05, 2022 1: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: Select all  Expand view
#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: Select all  Expand view
#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.04
Horizon
 
Posts: 1297
Joined: Fri May 23, 2008 1:33 pm

Re: TWebView:Destroy method does not close the window.

Postby Giovany Vecchi » Fri Aug 05, 2022 2: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: Select all  Expand view
#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
User avatar
Giovany Vecchi
 
Posts: 209
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: TWebView:Destroy method does not close the window.

Postby Horizon » Fri Aug 05, 2022 2: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: Select all  Expand view
#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.04
Horizon
 
Posts: 1297
Joined: Fri May 23, 2008 1:33 pm

Re: TWebView:Destroy method does not close the window.

Postby Giovany Vecchi » Fri Aug 05, 2022 3: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.
User avatar
Giovany Vecchi
 
Posts: 209
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: TWebView:Destroy method does not close the window.

Postby Horizon » Fri Aug 05, 2022 8:19 pm

Hi Antonio,

Can you help me please?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1297
Joined: Fri May 23, 2008 1:33 pm

Re: TWebView:Destroy method does not close the window.

Postby Horizon » Sat Aug 06, 2022 9: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 ::Super:New(....). Sorry for making you unnecessarily busy.

This is full working my second example (Created with the idea taken from Giovany's examples.)
Code: Select all  Expand view
#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.04
Horizon
 
Posts: 1297
Joined: Fri May 23, 2008 1:33 pm

Re: TWebView:Destroy method does not close the window.

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

Re: TWebView:Destroy method does not close the window.

Postby cmsoft » Sat Aug 06, 2022 7:32 pm

BCC7
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: TWebView:Destroy method does not close the window.

Postby Antonio Linares » Sun Aug 07, 2022 5:31 am

Enviadas! :-)
regards, saludos

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

Re: TWebView:Destroy method does not close the window.

Postby Otto » Sun Aug 07, 2022 6: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6092
Joined: Fri Oct 07, 2005 7:07 pm

Re: TWebView:Destroy method does not close the window.

Postby Antonio Linares » Sun Aug 07, 2022 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TWebView:Destroy method does not close the window.

Postby Otto » Sun Aug 07, 2022 10:00 am

Dear Antonio,
thank you so much and have a nice Sunday.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6092
Joined: Fri Oct 07, 2005 7:07 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 41 guests