TWebView2

Post Reply
User avatar
Ari
Posts: 247
Joined: Fri Feb 03, 2006 4:21 pm
Location: São Paulo, SP - Brazil
Been thanked: 2 times
Contact:

TWebView2

Post by Ari »

Olá,

Vou tentar explicar minha dificuldade:

Estou modificando o meu ERP, e criei classes que já funcionam no GUI, e também no HTML, a mesma classe criada em GUI é redesenhada no HTML.

(quando eu modifico algo no FiveWin já refrete a modificação no desenho HTML)

E estou usando EasyUI + Javascript + Json, e conforme código abaixo e abro a primeira página e a partir dele preciso acionar uma outra classe que gera a página de um relatorio por exemplo, eu não estou sabendo criar o javascript e passar para o Harbour qual a classe criar HTML, e em seguida reapresentar a nova página, dei uma olhada no SendToFWH(), É possivel passar um nome classe por este comando ?

E dentro da página do relatório botoes para imprimir, pdf, dashboard, excel, etc. Passei olhando os exemplos e não consegui nada.

Antes tudo isso já funcionava com o mod_harbour, mas isso precisa de um servidor grande, apache, etc.. e quando vi que posso ter o Browse Edge dentro do APP achei genial. Estou modificando para simplificar as coisas

eu uso FWH 2410 e tambem tenho FWH 2501.

Code: Select all | Expand


/*========================================================================
                       SISREV INFORMATICA LTDA.
              Prestando serviços com qualidade desde 1993
                       CNPJ: 02.623.572/0001-52
                       CNPJ: 02.623.572/0002-33
                          www.sisrev.com.br
  ========================================================================
   Sistema..: Sisrev-Win 5.0
   Autor(es): Ariovaldo da Costa Foliene
   Aplicação: TVWeb
   Notas....: Abre as páginas do Sisrev-Web - Microsoft Edge WebView2
   Data.....: 10-03-2025  
  ========================================================================
   TVisual--+
            |
            +--TVisualForm--+  
                            |
                            +--TVWeb.prg
   ========================================================================                                                     
*/

#include "fivewin.ch"
#include "Objects.ch"
#include "\sis\fsql901\include\rede.ch"

* ========================================================================
CLASS TVWeb FROM TVisualForm
* ========================================================================
  DATA cPage   
  DATA oWebView
    
  METHOD New() CONSTRUCTOR
  METHOD AddControl()
  METHOD BuildMenu()
    
END CLASS

* ========================================================================
METHOD New( xcPage, xcNome ) CLASS TVWeb
* ========================================================================

#ifdef __XHARBOUR__
  
  TVWebMsg() ; return Self
  
#endif
    
  DEFAULT xcPage := ""
  DEFAULT xcNome := Empresas(1)  
  
  ::Super:New("rel")
  
  ::cNome       := xcNome
  ::cPage       := "http://localhost:3000/" + xcPage  // nodejs
  ::lToolBar    := FALSE  
  ::lTask       := FALSE
  ::lRastrear   := FALSE
   
  ::AddControl()
  
  ::oWebView:oWnd:bValid := {|| ::oWebView:Terminate(),;
                                  WndMain():Show()    ,;
                                  WndMain():SetFocus(), TRUE }
                                
return Self

* ========================================================================
METHOD AddControl() CLASS TVWeb
* ========================================================================

#ifndef __XHARBOUR__

  ::oWebView:= TWebView2():New()
  
  ::oWebView:SetTitle( WebTitle("Sisrev-Web") ) 
  ::oWebView:SetUserAgent( WebAgent() )
  ::oWebView:oWnd:bResized := {|| ::oWebView:oWnd:Maximize() }
  ::oWebView:oWnd:SetMenu( ::BuildMenu() )  
  ::oWebView:oWnd:SetColor( CLR_BLACK ,nRGB( 231, 242, 255 )  )
  ::oWebView:oWnd:l2007    := .T.
  ::oWebView:SetSize( WndWidth( ::oWebView:oWnd:hWnd ) - 15, WndHeight( ::oWebView:oWnd:hWnd ) - 58 )  
 
  ::oWebView:Navigate( ::cPage )  
  
  ::oWebView:OpenDevToolsWindow(.F.)
  ::oWebView:ShowDownloads(.F.)    
  ::oWebView:oWnd:bInit := {|| ::oWebView:oWnd:Maximize() }
                                  
  ::oWebView:Run()  
  ::oWebView:Destroy()
  
  WndMain():Hide()
 
#endif

return nil

* =========================================================================
METHOD BuildMenu() CLASS TVWeb
* =========================================================================
  local oMenu

  MENU oMenu 
     MENUITEM "Fechar" ACTION ::oWebView:oWnd:End()
  ENDMENU
   
return oMenu 

* =========================================================================
Function TVWebMsg()
return Msg("** Esta funcionidade disponível para HarBour **")  
* =========================================================================

* =========================================================================
Function WebAgent()
* =========================================================================
return "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" 

Thanks,
Ari

FWH 2501 - Harbour 3.2.0 - Embarcadero 7.43 - MySQL
São Paulo - SP - Brasil
www.sisrev.com.br
User avatar
Ari
Posts: 247
Joined: Fri Feb 03, 2006 4:21 pm
Location: São Paulo, SP - Brazil
Been thanked: 2 times
Contact:

Re: TWebView2

Post by Ari »

I'll try to explain my difficulty:

I'm modifying my ERP, and I created classes that already work in the GUI, and also in HTML, the same class created in GUI is redesigned in HTML.

(when I modify something in FiveWin, the modification is already reflected in the HTML design)

And I'm using EasyUI + Javascript + Json, and according to the code below, I open the first page and from there I need to trigger another class that generates the page of a report, for example. I don't know how to create the javascript and pass to Harbour which class to create HTML, and then re-present the new page. I took a look at SendToFWH(), is it possible to pass a class name through this command?

And within the report page, buttons to print, pdf, dashboard, excel, etc. I looked at the examples and couldn't find anything.

Before all this already worked with mod_harbour, but this requires a large server, Apache, etc. and when I saw that I can have Browse Edge inside the APP I thought it was great. I'm modifying it to simplify things

I use FWH 2410 and I also have FWH 2501.
Thanks,
Ari

FWH 2501 - Harbour 3.2.0 - Embarcadero 7.43 - MySQL
São Paulo - SP - Brasil
www.sisrev.com.br
User avatar
Antonio Linares
Site Admin
Posts: 42655
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 67 times
Been thanked: 96 times
Contact:

Re: TWebView2

Post by Antonio Linares »

Dear Ari,

Please post some screenshots to get a better idea of what you need

many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Lailton
Posts: 177
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Has thanked: 2 times
Been thanked: 11 times
Contact:

Re: TWebView2

Post by Lailton »

That's really nice thing about it.
I have too some apps already using the webview and some HTMLs to render the screens.

Image
Image

It is awesome combine FWH with WebView + HTML/JS/CSS.
we can make nice UI and using bind call some command windows ( or any other OS ) to run procedure that normally is not
allowed by the browser. there's no limit.
Regards,
Lailton Fernando Mariano
User avatar
vilian
Posts: 989
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Has thanked: 3 times
Contact:

Re: TWebView2

Post by vilian »

that is really interesting and it´ll be great to see new code examples of this.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
leandro
Posts: 1771
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Has thanked: 49 times
Been thanked: 13 times
Contact:

Re: TWebView2

Post by leandro »

Buenos días

No se si pueda ayudar

viewtopic.php?p=274665#p274665
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 24.09 ] [ xHarbour 64 bits) ]
User avatar
Ari
Posts: 247
Joined: Fri Feb 03, 2006 4:21 pm
Location: São Paulo, SP - Brazil
Been thanked: 2 times
Contact:

Re: TWebView2 [resolvido]

Post by Ari »

Menu de Relatórios:

Sisrev-Win
Image

Sisrev-Web
Image

Sisrev-Win - Exemplo de Relatório de faturamento
Image

Sisrev-Web
Image

Sisrev-Win - Exemplo de Relatório de faturamento
Image

Sisrev-Web
Image


Resolvi assim:

Code: Select all | Expand

::oWebView:= TWebView2():New()
  
  ::oWebView:SetTitle( WebTitle("Sisrev-Web") ) 
  ::oWebView:SetUserAgent( WebAgent() )
  ::oWebView:oWnd:bResized := {|| ::oWebView:oWnd:Maximize() }
  ::oWebView:oWnd:SetMenu( ::BuildMenu() )  
  ::oWebView:oWnd:SetColor( CLR_BLACK ,nRGB( 231, 242, 255 ) )
  ::oWebView:oWnd:l2007    := .T.
  ::oWebView:SetSize( WndWidth(  ::oWebView:oWnd:hWnd ) - 15,;
                      WndHeight( ::oWebView:oWnd:hWnd ) - 58 )  

  ::oWebView:Navigate( ::cPage )  

  ::oWebView:bOnBind  := { |cJson| ExecWeb(cJson) }  <<<< ----------------------- aqui
    
  ::oWebView:OpenDevToolsWindow(.F.)
  ::oWebView:ShowDownloads(.F.)    
  ::oWebView:oWnd:bInit := {|| ::oWebView:oWnd:Maximize() }
                                  
  ::oWebView:Run()  
  ::oWebView:Destroy()
JavaScript

Code: Select all | Expand

  <form id="formbut" name="formbut" autocomplete="on" accept-charset="UTF-8" onsubmit="return validateForm()">
         <div>
         <a href="#" id="barrasuperior" class="easyui-linkbutton easyui-tooltip"  data-options="iconAlign:'top',iconCls:'fechar',content:'Fechar',width:'100',height:'65'" onclick="$('#win').window('close')">Fechar</a>
         <a href="#" id="barrasuperior" class="easyui-linkbutton easyui-tooltip"  data-options="iconAlign:'top',iconCls:'start',content:'OK-confirma opção',width:'100',height:'65'" onclick="javascript:Retorno();">Executar</a>
         </div>

         <input type="hidden" id="Usuario"      name="Usuario"   value="33">
         <input type="hidden" id="cNomTBL"      name="cNomTBL"   value="">
         <input type="hidden" id="nQual"        name="nQual"     value="2">
         <input type="hidden" id="cNome"        name="cNome"     value="<b>Centro de Relatórios</b>">
         <input type="hidden" id="cSubTitle"    name="cSubTitle" value="">
         <input type="hidden" id="Classe"       name="Classe"    value="TVBREL">
         <input type="hidden" id="registro"     name="registro"  value="">
         <input type="hidden" id="cDg"          name="cDg"    value="">

        <!-- DataGridRelWeb -->
        <table id="dg" class="easyui-datagrid"   pagination="true" singleSelect="true" remoteSort="false" striped="true" norap fitcolumns="true" pageSize="20"                            
          pagePosition="top" autoRowHeight="false" emptyMsg="Não foi encontrado registros" pageList="[10,15,20,25,30,35,40,50,100]" 
		                   style="width:auto;height:auto;" url="/sisrev/json/tvbreldiversos.json" method="get">          
         <thead>
         <tr>
         <th data-options="field:'CK' , checkbox:true"></th>
         <th data-options="field:'Num', width:10, align:'center'">Opção</th>
         <th data-options="field:'Descricao', sortable:true, width:100"><b>Descrição</b></th>
         </tr>
         </thead>
         </table>
         <script>
         $('#dg').datagrid({
           onClickRow:function(index,row){
           SendToFWH('TVBREL():TVBLISOPC('+row.Num+',"'+row.Descricao+'")')  <<<<< ------------------ aqui
          	}
           })

         </script>

         <script>
            $(function(){
               var dg = $('#dg').datagrid();
               dg.datagrid('enableFilter');})

         </script>
         </form>

Code: Select all | Expand


* ========================================================================
Function ExecWeb( cData )
* ========================================================================
   
  if ValType( cData ) == "A"
     cData := HB_VALTOEXP(cData) /* converts any data type to STR Value */
     cData := strtran( cData, "{", "")
     cData := strtran( cData, "}", "")
     cData := strtran( cData, "'", "")
  Endif  

  OnGet( "&classe=" + cData )
   
return nil
Thanks,
Ari

FWH 2501 - Harbour 3.2.0 - Embarcadero 7.43 - MySQL
São Paulo - SP - Brasil
www.sisrev.com.br
Post Reply