TWebView:Destroy method does not close the window.

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

Postby Antonio Linares » Sun Jul 31, 2022 6:03 pm

Dear Giovany,

Do you use it from a MDI environment as the posted examples ?
regards, saludos

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

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

Postby Giovany Vecchi » Sun Jul 31, 2022 7:23 pm

Hi Antonio, In this example I'm using it, but it also works without being MDI.
Download the link or look at the sources.
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.

Postby Antonio Linares » Sun Jul 31, 2022 9:30 pm

Dear Giovany,

Many thanks for your example.

In your PRGs I don't see any MDICHILD window being created with a WebView inside
regards, saludos

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

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

Postby Giovany Vecchi » Sun Jul 31, 2022 10:23 pm

Open WebView.prg on line 33 and put 'MDICHILD' then in the Samples menu call 'Test with Fivewin window' which will open a fivewin child window with webview2 handle

Code: Select all  Expand view  RUN
FUNCTION WEB_VIEW_TST_WND_FW()
   Local lc_oWndTst
   Local lc_oWebViewFw

   DEFINE WINDOW lc_oWndTst FROM 100, 100 TO 768, 1024 ;
      PIXEL ;
      TITLE "Teste WebView2" MDICHILD

      lc_oWndTst:bInit := <||
         lc_oWebViewFw := WebViewFw():New(lc_oWndTst)
         lc_oWebViewFw:WebViewFw_Start()
         lc_oWebViewFw:WebViewFw_Navigate("http://www.google.com.br")
         lc_oWebViewFw:WebViewFw_Run()
         Return Nil
      >// cEnd

      lc_oWndTst:bValid := <||
         lc_oWebViewFw:End()
         Return .T.
      >//cEnd
   
   ACTIVATE WINDOW lc_oWndTst NORMAL

RETURN NIL
 
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.

Postby Horizon » Mon Aug 01, 2022 11:27 am

Hi Antonio,

Can you please to help me to create wrapper WebView_Terminate for msvc? It is in WebView.dll but I could not access.

Thanks.
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 Antonio Linares » Mon Aug 01, 2022 12:01 pm

Dear Hakan,

I have already implemented it. I send you the libs this evening, I have to go now...

Do you need them for MSVC 32 bits ?
regards, saludos

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

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

Postby Horizon » Mon Aug 01, 2022 12:05 pm

Antonio Linares wrote:Dear Hakan,

I have already implemented it. I send you the libs this evening, I have to go now...

ok
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 Antonio Linares » Mon Aug 01, 2022 12:10 pm

msvc 32 bits ?
regards, saludos

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

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

Postby Horizon » Mon Aug 01, 2022 12:16 pm

Antonio Linares wrote:msvc 32 bits ?

yes
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 » Mon Aug 01, 2022 12:20 pm

Horizon wrote:
Antonio Linares wrote:msvc 32 bits ?

yes

and TWebView class if you have changed.
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 Antonio Linares » Mon Aug 01, 2022 11:34 pm

Already sent

best regards
regards, saludos

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

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

Postby Horizon » Wed Aug 03, 2022 6:49 pm

Hi Antonio,

Has our WEBVIEW_CREATE(,::oWndDlgContainer:hWnd) function container dialog parameter?

Code: Select all  Expand view  RUN
void * webview_create(int debug, void * window );
 


Code: Select all  Expand view  RUN
// Creates a new webview instance. If debug is non-zero - developer tools will
// be enabled (if the platform supports them). Window parameter can be a
// pointer to the native window handle. If it's non-null - then child WebView
// is embedded into the given parent window. Otherwise a new window is created.
// Depending on the platform, a GtkWindow, NSWindow or HWND pointer can be
// passed here.
HB_FUNC( WEBVIEW_CREATE )
{
   INT iDebug = ( INT ) 1 ;
   HWND hWnd = ( HWND ) fw_parH(2) ;
   if ( HB_ISNUM( 2 ) )
      hb_retptr( webview_create( iDebug , &hWnd ));
   else
      hb_retptr( webview_create( iDebug , 0 ));
}
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 Antonio Linares » Thu Aug 04, 2022 7:09 am

Dear Hakan,

I have already implemented it though using a different code from yours:
Code: Select all  Expand view  RUN
HB_FUNC( WEBVIEW_CREATE )
{
   if( ! hDLL )
      hDLL = LoadLibrary( "webview.dll" );

   if( ! hDLL )
   {
      MessageBox( 0, "Could not load webview.dll", "Error", MB_OK | MB_ICONERROR );  
      hb_ret();
   }  
   else
   {
      HWND hWnd = ( HWND ) hb_parnll( 2 );

      if( hWnd != 0 )
         hb_retptr( ( ( webview_create * ) GetProcAddress( hDLL, "webview_create" ) )( hb_parnl( 1 ), &hWnd ) );
      else
         hb_retptr( ( ( webview_create * ) GetProcAddress( hDLL, "webview_create" ) )( hb_parnl( 1 ), 0 ) );
   }  
}


In Class TWebView:
Code: Select all  Expand view  RUN
  METHOD New( nDebug, hWndParent ) INLINE ( ::hWebView := WebView_Create( nDebug, hWndParent ), AAdd( aWebViews, Self ), Self )
 

I am emailing you the modified libs
regards, saludos

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

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

Postby Horizon » Thu Aug 04, 2022 7:44 pm

Thank you Antonio,

With this last change, TWebView is easier to control.

Code: Select all  Expand view  RUN
#include "FiveWin.ch"
function Main()
  local oWnd, oBar
    public pb_oWebView

   DEFINE WINDOW oWnd

   DEFINE BUTTONBAR oBar 3D OF oWnd SIZE 60, 60

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

   ACTIVATE WINDOW oWnd

return nil

function Open_Google( oWnd )
LOCAL cHtml:="https://www.google.com/"
local oWndChild, oWebView

    IF !EMPTY(pb_oWebView)
        MsgAlert("There is already WINDOW")
        return
    ENDIF
  DEFINE WINDOW oWndChild TITLE "My Test FW Window_"+TIME() ;
    FROM 100, 100 TO 768, 1024 PIXEL
  oWndChild:bInit := <||
        oWebView := TOB_WebView():New(oWndChild)
        oWebView:Navigate(cHtml)
        oWebView:Run()                              // We dont need when oWndChild
        pb_oWebView := oWebView
     Return Nil
  >
 
    oWndChild:bValid := <||
       oWebView:Destroy()
       Return .T.
    >
   
  ACTIVATE WINDOW oWndChild  
   
return nil

PROCEDURE Close_Google(oWnd)
LOCAL oWebView := pb_oWebView
    If EMPTY(pb_oWebView)
        MsgAlert("There is NOT any WINDOW") 
        return 
    ENDIF
    If !HB_ISNIL(oWebView:oWndDlgContainer)
        oWebView:oWndDlgContainer:End()
        pb_oWebView:=nil
    EndIf   
return nil
*------------------------------------------------------------------------------------------
CLASS TOB_WebView FROM TWebView
    Data oWndDlgContainer

    METHOD New(oWndDlgContainer) Constructor
    Method Run()
   
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

Method Run() Class TOB_WebView
    IF HB_ISNIL(::oWndDlgContainer)
        If !::lStartRun
          ::super:Run()
        EndIf
        ::lStartRun := .T.
  ENDIF
Return Nil
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 cmsoft » Thu Aug 04, 2022 10:10 pm

Antonio, para probar, hay que descargar nuevamente las librerias?
Ya que pruebo el ejemplo de Hakan y me quedan abiertas ventanas...
Desde ya muchas gracias
User avatar
cmsoft
 
Posts: 1292
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Antonio Linares and 42 guests