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?