TWebView:Destroy method does not close the window.

User avatar
Antonio Linares
Site Admin
Posts: 42595
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 38 times
Been thanked: 86 times
Contact:

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

Post by Antonio Linares »

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
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

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

Post by cmsoft »

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

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

Post by cmsoft »

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!
Horizon
Posts: 1327
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 5 times

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

Post by Horizon »

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

#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

#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
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

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

Post by Giovany Vecchi »

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

#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
Horizon
Posts: 1327
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 5 times

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

Post by Horizon »

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

#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
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

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

Post by Giovany Vecchi »

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.
Horizon
Posts: 1327
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 5 times

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

Post by Horizon »

Hi Antonio,

Can you help me please?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
Posts: 1327
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 5 times

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

Post by Horizon »

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

#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
User avatar
Antonio Linares
Site Admin
Posts: 42595
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 38 times
Been thanked: 86 times
Contact:

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

Post by Antonio Linares »

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
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

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

Post by cmsoft »

BCC7
User avatar
Antonio Linares
Site Admin
Posts: 42595
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 38 times
Been thanked: 86 times
Contact:

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

Post by Antonio Linares »

Enviadas! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 6412
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 27 times
Been thanked: 2 times
Contact:

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

Post by Otto »

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
Antonio Linares
Site Admin
Posts: 42595
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 38 times
Been thanked: 86 times
Contact:

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

Post by Antonio Linares »

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
Otto
Posts: 6412
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 27 times
Been thanked: 2 times
Contact:

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

Post by Otto »

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
********************************************************************
Post Reply