FWH 24.02 new Class TWebView2

FWH 24.02 new Class TWebView2

Postby Antonio Linares » Thu Feb 29, 2024 4:59 am

Dear friends,

when we started looking for info to use WebView2 from FWH we found https://github.com/webview/webview

the code looked quite complex, so we decided to try the webview.dll which it is what we have been using in FWH until now

recently I talked about it to Bruno Cantero and as he is a very good expert with OLE and C++ and he decided to build his own version without using the DLL

he shared it with me and I started testing it :-)

there are some pros and cons:

1. we no longer need to use webview.dll neither WebView2Loader.dll, which is great news! :-)

2. webview.dll way of working does not follow the original Microsoft WebView2 implementation, so we are still working to find compatibility with FWH Class TWebView

that is why we have decided, in the meantime, to implement a new Class TWebView2 until we make it as much compatible as possible with existing Class TWebView.

Once we reach full compatibility, we will drop existing Class TWebView, so Class TWebView2 will be renamed as Class TWebView. And we will no longer need to use those DLLs :-)

In FWH 24.02 you can find in FWH\samples the original examples for Class TWebView. You can also find copies of them, in example: webview_2.prg which are the equivalents for Class TWebView2. Please notice that there are some differences, so you will have to review your current code to get it properly working with new Class TWebView2 (in the future it will become the official FWH Class TWebView)

Thanks for reading this message, we wanted to clearly explain what we are doing and why :-)
regards, saludos

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

Re: FWH 24.02 new Class TWebView2

Postby Otto » Fri Mar 01, 2024 3:18 pm

Dear Antonio,

I was preparing an example for a PDF with preview, which Anton had already solved more simply in the forum in the meantime.

I had the problem here that I wanted to display the PDF in an iframe. I then realized that the webview2 denies access.
Then I wanted to allow access with oWebView:SetAllowFileAccess(.t.), but this is not supported.

Is this possible with the new version?

Best regards,
Otto

Not allowed to load local resource: file:///C:/fwh2023/samples/231113_FactSheet.pdf

Code: Select all  Expand view

function Main()

   local oWebView := TWebView():New(1)
    local cHtml := memoread( "c:\fwh2023\samples\pdfviewer.html" )
 
//  oWebView:SetAllowFileAccess( .t. )
   oWebView:SetHtml( cHtml )
   
 
   oWebView:SetTitle( "Microsoft Edge WebView working from FWH" )
   oWebView:SetSize( 1200, 800 )
   oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
   sleep( 600 )
   oWebView:Run()
   oWebView:Destroy()

return nil
 



Code: Select all  Expand view


<!DOCTYPE html>
<html lang="de">
  <head>
   <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Restaurant Tischplan</title>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

  <style>
     @media print {
     .border-black {
    border-color: black !important;
    border-style: solid !important;
    border-width: 1px !important;
}
}
    </style>

  </head>
<body>
    <div class="container mt-5">
        <h2>PDF-Datei anzeigen und drucken</h2>
        <!-- Druck-Button -->
        <button id="printButton" class="btn btn-primary">Drucken</button>
        <!-- PDF-Datei einbetten -->
        <iframe id="pdfViewer"  src="file:///C:/fwh2023/samples/231113_FactSheet.pdf" width="100%" height="600px" style="border: none;"></iframe>
    </div>

    <!-- JavaScript für Druckfunktionalität -->
    <script>
        $(document).ready(function() {
            $('#printButton').click(function() {
                var pdfFrame = document.getElementById('pdfViewer');
                pdfFrame.focus();
                pdfFrame.contentWindow.print();
            });
        });
    </script>
</body>


 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6006
Joined: Fri Oct 07, 2005 7:07 pm

Re: FWH 24.02 new Class TWebView2

Postby Antonio Linares » Sat Mar 02, 2024 8:22 am

Dear Otto,

Looking in the webview2 docs I can't find a SetAllowFileAccess()
https://github.com/FiveTechSoft/FiveTech_wiki/blob/main/FiveWin/WebView/microsoft-edge-webview2-reference-win32-webview2-1.0.2365.46.pdf

I am going to ask Bruno about it as he already has a PDF viewer using webview2
regards, saludos

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

Re: FWH 24.02 new Class TWebView2

Postby Antonio Linares » Sat Mar 02, 2024 8:25 am

He just answered me saying that he didn't use that, it is not needed

He just hides the bar options using:
put_HiddenPdfToolbarItems( … constants to hide )

from interface settingsd

webview2 has many options, please review the above Microsoft docs url for it
regards, saludos

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

Re: FWH 24.02 new Class TWebView2

Postby csincuir » Wed Mar 13, 2024 2:38 pm

Hola Antonio,
Haciendo pruebas con la nueva clase TWebView2, primero, excelente que ahora ya no se necesitan las dll's

Segundo, haciendo pruebas con el ejemplo "\samples\webviewlogin.prg", el metodo "Bind()" no lo tiene definido la clase TWebView2(),
por lo que la puse en comentarios y funcionó correctamente, mostrándome el dialogo del Login y me envía la respuesta, pero tuve que
tratar la misma de otra forma ya que envía un array con un hash en la posición 1, por lo que no es necesario utilizar la función hb_jsonDecode().

Pero veo que también el método "Return()" no lo tiene definido la nueva clase TWebView2() por lo que ya no pude enviar la respuesta.

Te envío los cambios que hice en el ejemplo por si sirve de algo, y voy a seguir haciendo pruebas con lo que se pueda con esta nueva clase TWebView2().

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWebView := TWebView2():New()

   oWebView:SetHtml( Html() )
   oWebView:SetTitle( "Please identify with your credentials" )
   oWebView:SetSize( 1200, 800 )
   oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
   //oWebView:Bind( "SendToFWH" )
   oWebView:bOnBind = { | cJson, cCalls | Login( cJson, cCalls, oWebView ) }
   sleep( 300 )
   oWebView:Run()
   oWebView:Destroy()

return nil

function Login( cJson, cCalls, oWebView )

   local hData
   
   //hb_jsonDecode( cJson, @hData )
   hData := cJson[1]

   //if hData[ 1 ][ "username" ] != "Antonio" .or. hData[ 1 ][ "password" ] != "1234"
   if hData[ "username" ] != "Antonio" .or. hData[ "password" ] != "1234"
      oWebView:Return( cCalls, 0, "{ 'result': 'incorrect values' }" )
   else
      oWebView:Return( cCalls, 0, "{ 'result': 'correct!' }" )
  endif

return nil  

function Html()

   local cHtml

   TEXT INTO cHtml
   <!DOCTYPE html>
   <html>
   <head>
     <title>Identify</title>
     <style>
     body {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100vh;
      background-color: #F2F2F2;
      font-family: Arial, sans-serif;
      margin: 0;
     padding: 0;
    }
   
      .container {
         max-width: 400px;
         margin: 0 auto;
         padding: 40px;
         background-color: #FFFFFF;
         border-radius: 5px;
         display: flex;
         flex-direction: column;
         align-items: center;
         box-shadow: 0px 0px 44px rgba(0, 0, 0, 0.7) !important;
         overflow:none !important;
       }
   
       .logo {
         margin-bottom: 40px;
         display: flex;
         align-items: center;
       }
   
       .logo img {
         max-width: 100%;
         height: auto;
       }
   
       .btn {
         display: inline-block;
         padding: 12px 24px;
         background-color: #4CAF50;
         color: #FFFFFF;
         font-size: 16px;
         text-decoration: none;
         border-radius: 5px;
         transition: background-color 0.3s ease;
       }
   
       .btn:hover {
         background-color: #45A049;
       }
         
       .form-group {
         margin-bottom: 20px;
       }
       
       .form-group label {
         display: block;
         font-size: 16px;
         font-weight: bold;
         margin-bottom: 5px;
         color: #333333;
       }
       
       .form-group input {
         width: 100%;
         padding: 12px;
         font-size: 16px;
         border-radius: 5px;
         border: 1px solid #CCCCCC;
       }
       
       .btn {
         display: inline-block;
         padding: 12px 24px;
         background-color: #4CAF50;
         color: #FFFFFF;
         font-size: 16px;
         text-decoration: none;
         border-radius: 5px;
         transition: background-color 0.3s ease;
       }
       
       .btn:hover {
         background-color: #45A049;
       }
       
       body {
         background-color: #3498db;
       }
       
       .btn {
         background-color: #2980b9;
       }
       
       .btn:hover {
         background-color: #1a5276;
   
      .logo {
         margin-bottom: 40px;
         }
   
         .logo img {
         max-width: 100%;
         height: auto;
         }            
       }
     
     .myinput {
       width: auto !important; 
     }
     
     .mybtn {
       text-align:center;
     }
     
     </style>
   </head>
   <body>
     <div class="container">
       <div class="logo">
         <img src="https://fivetechsupport.com/forums/styles/prosilver/imageset/site_logo.gif" alt="Logo">
       </div>
       <form id="login-form" action="#" method="POST">
         <div class="form-group">
           <label for="username">Username:</label>
           <input type="text" id="username" name="username" class="myinput" required>
         </div>
         <div class="form-group">
           <label for="password">Password:</label>
           <input type="password" id="password" name="password" class="myinput" required>
         </div>
       <div class="form-group mybtn" >
       <button type="submit" class="btn">Start session</button>
       </div>
       </form>
     </div>
   
     <script>
       document.getElementById('login-form').addEventListener('submit', function(event) {
         event.preventDefault();
   
         var username = document.getElementById('username').value;
         var password = document.getElementById('password').value;
         var data = {
           username: username,
           password: password
         };
   
         var s = SendToFWH(data).then( s => { alert(s.result); } );
       });
     </script>
   </body>
   </html>
   ENDTEXT

return cHtml
 


Saludos cordiales.

Carlos.
csincuir
 
Posts: 396
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: FWH 24.02 new Class TWebView2

Postby Antonio Linares » Wed Mar 13, 2024 4:24 pm

Estimado Carlos,

me alegro mucho de comenzar a recibir feedback de la nueva clase TWebView2, gracias! :-)

Como has advertido, hay diferencias entre esta nueva clase y la anterior basada en la DLL. Hay que destacar que los autores de webview.dll
hicieron ciertas interpretaciones que difieren un tanto de la forma original de uso que Microsoft implementó.

El método Eval() devuelve el resultado de la evaluación ahora, por que MsgInfo( oWebView:Eval( "123" ) ) devolverá 123, y eso sucede igualmente
si se llama a cualquier código javascript que devuelva un cierto valor. Por lo tanto ya no es necesario llamar a "SendToFWH()" desde el método Eval()
pues el resultado nos viene automaticamente de vuelta.

SendToFWH() solo se usa para hacer llamadas desde javascrip al EXE, y si, es posible que notes algunas diferencias con la anterior clase TWebView.
El método Return() aun no está muy claro como hemos de implementarlo, hay que hacer pruebas y ver cual es la forma idónea de hacerlo.

Agradezco mucho tus comentarios, pruebas y resultados. Lo bueno de esta nueva clase TWebView2 es que ya nos olvidamos de las DLLs y además ya seguimos
exactamente el modelo implementado por Microsoft.
regards, saludos

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

Re: FWH 24.02 new Class TWebView2

Postby csincuir » Fri Mar 15, 2024 3:13 pm

Antonio,
Siguiendo con las pruebas de la TWebView2, realice unos pequeños cambios a la clase TWebView2 para acomodarlos al ejemplo "webviewlogin.prg" y poder darle funcionalidad si el usuario ingresa correctamente los datos, presentar la ventana principal de un sistema.

Code: Select all  Expand view
#include "FiveWin.ch"

#define GWL_STYLE        -16

static aWebViews := {}

static oWnd, lLogin

function Main()

   local oWebView

   lLogin := .f.
   oWebView := TWebView2():New(NIL,.F.)
   oWebView:SetHtml( Html() )
   oWebView:SetTitle( "FWH 2404 - WebView2" )
   oWebView:SetSizeWnd( 675, 675 )
   oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
   //oWebView:Bind( "SendToFWH" )
   oWebView:bOnBind = { | cJson, cCalls | Login( cJson, cCalls, oWebView ) }
   //sleep( 300 )
   oWebView:Center()  
   
   oWebView:Run()
   //oWebView:Destroy()

   If lLogin
      WndSistema()
   End
   
return nil

function Login( cJson, cCalls, oWebView )

   local hData

   //hb_jsonDecode( cJson, @hData )
   
   hData := cJson
   If hData[ 1 ][ "username" ] == "CancelarIngreso"
      If MsgNoYes("Esta seguro de cancelar el ingreso?","Confirme por favor...")
         oWebView:End()
      End
   End
   if hData[ 1 ][ "username" ] != "Antonio" .or. hData[ 1 ][ "password" ] != "1234"
      MsgAlert("Datos de usuario incorrectos","Verifique por favor")
   else
      //oWebView:Return( cCalls, 0, "{ 'result': 'correct!' }" )
     lLogin := .t.
     oWebView:End()

  endif

return nil  


//-------------------------------------------------------------------
FUNCTION WndSistema()

   local oBar

   SET _3DLOOK ON

   USE Customer ALIAS Clients
   USE Sales NEW
   SELECT Clients

   DEFINE WINDOW oWnd TITLE "FWH 2404 - WebView2" MDI ;
      MENU BuildMenu() COLOR "N/W"

   DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007

   DEFINE BUTTON OF oBar ACTION MsgInfo( "Click" ) ;
      FILENAME "..\bitmaps\attach.bmp" PROMPT "Attach"

   DEFINE BUTTON OF oBar ACTION MsgInfo( "Click" ) ;
      FILENAME "..\bitmaps\calendar.bmp" PROMPT "Calendar"

   DEFINE BUTTON OF oBar ACTION MsgInfo( "Click" ) ;
      FILENAME "..\bitmaps\people2.bmp" PROMPT "Clients"

   DEFINE BUTTON OF oBar ACTION MsgInfo( "Click" )

   SET MESSAGE OF oWnd TO "Testing FWH 2404 - WebView2" CENTERED

   ACTIVATE WINDOW oWnd MAXIMIZED;
      VALID MsgYesNo( "Desea salir del sistema?", "Confirme por favor" )

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "&Archivos"
      MENU
         MENUITEM "&Clientes..." ACTION  MsgInfo( "Click" ) ;
            MESSAGE "Clients management"

         MENUITEM "&Reportes..." ACTION MsgInfo( "Click" )
         SEPARATOR
         MENUITEM "&Salida" ACTION oWnd:End() ;
            MESSAGE "End this test"

      ENDMENU


   ENDMENU

return oMenu

//----------------------------------------------------------------------------//

Function Html()
local cHtml

TEXT INTO cHtml

<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Design by foolishdeveloper.com -->
    <title>Sistema Empresarial - SEM</title>
 
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;500;600&display=swap" rel="stylesheet">
   
    <!--Stylesheet-->
    <style media="screen">
        *,
        *:before,
        *:after{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        body{
            background-color: #080710;
        }
        .background{
            width: 430px;
            height: 520px;
            position: absolute;
            transform: translate(-50%,-50%);
            left: 50%;
            top: 50%;
        }
        .background .shape{
            height: 200px;
            width: 200px;
            position: absolute;
            border-radius: 50%;
        }
        .shape:first-child{
            background: linear-gradient(
                #1845ad,
                #23a2f6
            );
            left: -80px;
            top: -80px;
        }
        .shape:last-child{
            background: linear-gradient(
                to right,
                #ff512f,
                #f09819
            );
            right: -30px;
            bottom: -80px;
        }
        form{
            height: 520px;
            width: 400px;
            background-color: rgba(255,255,255,0.13);
            position: absolute;
            transform: translate(-50%,-50%);
            top: 50%;
            left: 50%;
            border-radius: 10px;
            backdrop-filter: blur(10px);
            border: 2px solid rgba(255,255,255,0.1);
            box-shadow: 0 0 40px rgba(8,7,16,0.6);
            padding: 50px 35px;
        }
        form *{
            font-family: 'Poppins',sans-serif;
            color: #ffffff;
            letter-spacing: 0.5px;
            outline: none;
            border: none;
        }
        form h3{
            font-size: 32px;
            font-weight: 500;
            line-height: 42px;
            text-align: center;
        }

        label{
            display: block;
            margin-top: 30px;
            font-size: 16px;
            font-weight: 500;
        }
        input{
            display: block;
            height: 50px;
            width: 100%;
            background-color: rgba(255,255,255,0.07);
            border-radius: 3px;
            padding: 0 10px;
            margin-top: 8px;
            font-size: 14px;
            font-weight: 300;
        }
        ::placeholder{
            color: #e5e5e5;
        }
        button{
            margin-top: 50px;
            width: 100%;
            background-color: #ffffff;
            color: #080710;
            padding: 15px 0;
            font-size: 18px;
            font-weight: 600;
            border-radius: 5px;
            cursor: pointer;
        }
        .botones{
          margin-top: 0px;
          display: flex;
        }
        .botones div{
          background: red;
          width: 165px;
          border-radius: 3px;
          padding: 5px 10px 10px 5px;
          background-color: rgba(255,255,255,0.0);
          color: #eaf0fb;
          text-align: center;
        }
        .botones div:hover{
          background-color: rgba(255,255,255,0.0);
        }
        .botones .fb{
          margin-left: 25px;
        }
        .botones i{
          margin-right: 4px;
        }

       .btn {
         display: inline-block;
         padding: 12px 24px;
         background-color: #2980b9;
         color: #FFFFFF;
         font-size: 16px;
         text-decoration: none;
         border-radius: 5px;
         transition: background-color 0.3s ease;
       }
   
       .btn:hover {
         //background-color: #45A049;
         background-color: #1a5276;   
       }
       
       .btnc {
         background-color: #af504c;
         padding: 12px 24px;
         font-size: 16px;
         transition: background-color 0.3s ease;
       }
       
       .btnc:hover {
         background-color: #1a5276;   
        }
       
    </style>
</head>
<body>
    <div class="background">
        <div class="shape"></div>
        <div class="shape"></div>
    </div>

    <form id="login-form" action="#" method="POST">
        <h3>Ingreso al Sistema</h3>

        <label for="username">Nombre:</label>
        <input type="text" placeholder="Nombre de Usuario" id="username" name="username" autofocus>

        <label for="password">Clave:</label>
        <input type="password" placeholder="Clave de usuario" id="password">

        <!--button>Ingreso</button-->
       
        <div class="botones">
            <div>
                <button class="btn">Ingresar</button>
            </div>
            <div>
                <button type="cancel" class="btnc" onclick="cancelalogin();">Cancelar</button>
            </div>
        </div>

    </form>
   
     <script>
       document.getElementById('login-form').addEventListener('submit', function(event) {
         event.preventDefault();
   
         var username = document.getElementById('username').value;
         var password = document.getElementById('password').value;
         var data = {
           username: username,
           password: password
         };
   
         var s = SendToFWH(data).then( s => { alert(s.result); } );
       });
       
       function cancelalogin() {
         event.preventDefault();
   
         var username = "CancelarIngreso";
         var password = "CancelarIngreso";
         var data = {
           username: username,
           password: password
         };
   
         var s = SendToFWH(data).then( s => { alert(s.result); } );
        }  
     </script>
</body>
</html>


ENDTEXT

return cHtml


//----------------------------------------------------------------------------//

CLASS TWebView2

   DATA hWebView
   DATA oWnd    
   DATA bOnBind

   METHOD New( oWndParent, lSysMenu ) CONSTRUCTOR //CASR

   METHOD Navigate( cURL ) INLINE WebView2_Navigate( ::hWebView, cURL )

   METHOD Center() INLINE ::oWnd:Center()  

   METHOD SetHtml( cHtml ) INLINE WebView2_SetHtml( ::hWebView, cHTML )  

   METHOD SetTitle( cText ) INLINE SetWindowText( ::oWnd:hWnd, cText )

   METHOD SetSize( nWidth, nHeight ) INLINE WebView2_SetSize( ::hWebView, nWidth, nHeight )
   
   METHOD SetSizeWnd( nWidth, nHeight ) INLINE  ::oWnd:SetSize( nWidth, nHeight )  //CASR

   METHOD SetUserAgent( cUserAgent ) INLINE WebView2_SetUserAgent( ::hWebView, cUserAgent )

   METHOD OpenDevToolsWindow( lOnOff ) INLINE WebView2_OpenDevToolsWindow( ::hWebView, If( Empty( lOnOff ), .T., lOnOff ) )

   METHOD Run() INLINE ::oWnd:Activate()

   METHOD SetParent( oWnd ) INLINE ( ::oWnd := oWnd, SetWindowLong( ::GetWindow(), GWL_STYLE, nOr( WS_CHILD, WS_VISIBLE ) ),;
          SetWindowPos( ::GetWindow(), 0, 0, 0, oWnd:nWidth, oWnd:nHeight, 4 ),;
          SetParent( ::GetWindow(), oWnd:hWnd ) )      

   METHOD GetWindow() INLINE ::oWnd:hWnd

   METHOD Eval( cJavaScript ) INLINE WebView2_Eval( ::hWebView, cJavaScript )  

   METHOD Terminate() VIRTUAL  

   METHOD Destroy() VIRTUAL
   
   METHOD Return( cRequest, nBindResult, cFromPrgToJS ) INLINE ;
      WebView_Return( ::hWebView, cRequest, nBindResult, cFromPrgToJS )


   METHOD End() INLINE ( WebView2_End( ::hWebView ), ::hWebView := 0, ::oWnd:End() )  //CASR

ENDCLASS        

//----------------------------------------------------------------------------//

METHOD New( oWndParent, lSysMenu ) CLASS TWebView2

   DEFAULT  lSysMenu := .t.
   
   if ! Empty( oWndParent ) .and. ! Empty( oWndParent:hWnd )
      ::hWebView = WebView2_New( oWndParent:hWnd )
      ::oWnd = oWndParent
   else
      If lSysMenu
         DEFINE WINDOW ::oWnd TITLE "WebView" COLOR "N/B"
      Else
         DEFINE WINDOW ::oWnd TITLE "WebView" COLOR "N/B" NoSysMenu
      End
     
      ::hWebView = WebView2_New( ::oWnd:hWnd )
      ::oWnd:bResized = { | nType, nWidth, nHeight | nType, ::SetSize( nWidth, nHeight ) }
   endif
   
   ::bOnBind = { | nErrorCode, cJsonResult, hWebView | hWebView,;
               MsgInfo( "errorCode: " + AllTrim( Str( nErrorCode ) ) + CRLF + ;
               "cJsonResult: " + cJsonResult ) }

   AAdd( aWebViews, Self )

return Self    


//----------------------------------------------------------------------------//

static function GetWebView( hWebView )

return aWebViews[ AScan( aWebViews, { | o | o:hWebView == hWebView } ) ]  

//----------------------------------------------------------------------------//

function WebView2_GetParams( cParams, hWebView )

   local oWebView := GetWebView( hWebView )
   local hJson

   hb_jsonDecode( cParams, @hJson )

   if ! Empty( oWebView:bOnBind )
      Eval( oWebView:bOnBind, hJson[ "params" ], oWebView )
   endif  

return nil  

//----------------------------------------------------------------------------//

function WebView2_GetValues( nErrorCode, cJsonResult, hWebView )

   local nAt := AScan( aWebViews, { | o | o:hWebView == hWebView } ), nResult

   if nAt != 0 .and. ! Empty( aWebViews[ nAt ]:bOnBind )
      nResult = Eval( aWebViews[ nAt ]:bOnBind, nErrorCode, cJsonResult, hWebView )
   endif  

return nResult


//----------------------------------------------------------------------------//

Image
El usuario es "Antonio" y la clave "12345"

En el codigo enviado, va la clase TWebView2 con los cambios realizados por mi persona marcados con "CASR"

Ahora, con una pregunta, como hago para que no aparezca el scroll vertical de la ventana del login??

Saludos cordiales.

Carlos.
csincuir
 
Posts: 396
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: FWH 24.02 new Class TWebView2

Postby Otto » Fri Mar 15, 2024 4:31 pm

Hello Carlos,
thank you. That is a very nice example.
Do you also have a version for webview2 old?

I haven't dealt with the new webview2 yet. But then I could look at the differences in programming.
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: 6006
Joined: Fri Oct 07, 2005 7:07 pm

Re: FWH 24.02 new Class TWebView2

Postby Natter » Sat Mar 16, 2024 4:32 pm

I understand that since version FWH2402, when using webview 2, I do not need to use webview.dll.
I have compiled an example chart.png from FWH2402. However, when I start, I get a call error message webview.dll Why ?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: FWH 24.02 new Class TWebView2

Postby csincuir » Sat Mar 16, 2024 5:00 pm

Otto wrote:Hello Carlos,
thank you. That is a very nice example.
Do you also have a version for webview2 old?

I haven't dealt with the new webview2 yet. But then I could look at the differences in programming.
Best regards,
Otto


Estimado Otto,
La clase original webview2.prg esta en el directorio "source" de la FWH2402, yo tome el codigo y lo agregue al ejemplo que coloque anteriormente, donde solo le hice unos pocos cambios en el tema de la ventana que contiene el objeto webview2.

Saludos cordiales.

Carlos
csincuir
 
Posts: 396
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: FWH 24.02 new Class TWebView2

Postby csincuir » Sat Mar 16, 2024 5:04 pm

Natter wrote:I understand that since version FWH2402, when using webview 2, I do not need to use webview.dll.
I have compiled an example chart.png from FWH2402. However, when I start, I get a call error message webview.dll Why ?


Hola Natter.
Para no usar la webview.dll cambia en el codigo esta linea:
Code: Select all  Expand view
local oWebView := TWebView():New()


Por esta otra linea:
Code: Select all  Expand view
local oWebView := TWebView2():New()
 


Solo agregale el "2" al nombre de la clase y ya no va a utilizar la "webview.dll"

Saludos cordiales.

Carlos.
csincuir
 
Posts: 396
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: FWH 24.02 new Class TWebView2

Postby Natter » Sat Mar 16, 2024 6:13 pm

Gracias, Carlos !
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests