TWebView:Destroy method does not close the window.

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

Postby Horizon » Sun Aug 07, 2022 3:43 pm

Deleted
Last edited by Horizon on Sun Aug 07, 2022 3:52 pm, edited 1 time in total.
Regards,

Hakan ONEMLI

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

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

Postby Horizon » Sun Aug 07, 2022 3:50 pm

Horizon wrote:Hi Antonio,

Some suggestion of TWebView class.

Code: Select all  Expand view
CLASS TOB_WebView FROM TWebView
    DATA nDebug                    
    DATA nEval_TimeOut              INIT 15
    DATA nTimeOut_Step              INIT .25
    DATA oWndDlgContainer
    DATA oMsgBar1, oMsgBar2
    DATA lReadyStateControl     INIT .T.

    .....
    ......
    METHOD Eval( cScript )
    METHOD IsIdle()
    METHOD ReadData(cScript)
    .....
    .....
   
ENDCLASS


METHOD Eval( cScript, lSkipControl ) CLASS TOB_WebView
DEFAULT lSkipControl:=.T.
   
    IF !lSkipControl
        ::super:Eval( cScript )
    ELSEIF ::IsIdle()
        ::super:Eval( cScript )
    ELSE
        MsgAlert(cScript+CRLF+"TimeOut."+CRLF+"Please ("+NTRIM(::nEval_TimeOut)+" ) increase the TimeOut_Step.","Error")
    ENDIF
RETURN

/*
With Mr. Otto's suggestion.
*/

METHOD IsIdle() CLASS TOB_WebView
LOCAL lResult:=.F., nSecond:=0, cTemp
    IF !::lReadyStateControl
        RETURN .T.
    ENDIF
    DO WHILE !lResult
        cTemp := ::ReadData("document.readyState")
        IF !HB_ISNIL(::oMsgBar1)
            ::oMsgBar1:SetText(cTemp)
        ENDIF
        IF cTemp = "complete"
            lResult := .T.
            EXIT
        ENDIF
        SysWait(::nTimeOut_Step)
        nSecond += ::nTimeOut_Step
        IF !HB_ISNIL(::oMsgBar2)
            ::oMsgBar2:SetText(NTRIM(nSecond))
        ENDIF      
        IF nSecond > ::nEval_TimeOut
            RETURN lResult
        ENDIF
    ENDDO
RETURN lResult

/*
    IF oWebView:IsIdle()
        oWebView:ReadData("document.documentURI")
    ENDIF
*/

METHOD ReadData(cScript, nTimeOut) CLASS TOB_WebView
LOCAL cResult:=""
DEFAULT nTimeOut:=::nTimeOut_Step
    cResultVar := ""
    ::super:Eval('SendToFWH( '+cScript+ ' )')   
    IF !HB_ISNIL(::oMsgBar1)
        ::oMsgBar1:SetText(cResultVar)
    ENDIF   
    SysWait(nTimeOut)
    cResult = MyJSONToText(cResultVar)
RETURN cResult

FUNCTION MyJSONToText(cText)
LOCAL hDatos := {=>}, cResult:=""
    IF EMPTY(cText)
        RETURN ""
    ENDIF
    hb_JsonDecode( cText, @hDatos )
    IF !EMPTY(hDatos)
        IF VALTYPE(hDatos)="A"
            IF VALTYPE(hDatos[1])="N"
                cResult := NTRIM(hDatos[1])
            ELSEIF VALTYPE(hDatos[1])="L"
                cResult := hDatos[1]
            ELSE
                cResult := ALLTRIM(hDatos[1])
            ENDIF
        ELSE
            IF VALTYPE(hDatos)="N"
                cResult := NTRIM(hDatos)
            ELSE
                cResult := ALLTRIM(hDatos)
            ENDIF
        ENDIF
    ENDIF
RETURN cResult
*------------------------------------------------------------------------------------------------------------
PROCEDURE GetDataFrom_WebView(cJson, nCalls)
    cResultVar := cJson
RETURN
*------------------------------------------------------------------------------------------------------------
 
Regards,

Hakan ONEMLI

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

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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