TWebView window size

TWebView window size

Postby Ruth » Thu Feb 01, 2024 7:57 am

Dear friends,

please can you help me. Is there a way to set a fixed minimum size for the "webview-window"?
this is our code:
Code: Select all  Expand view
function Main()
    local hPost := {}
   
    oWebView := TWebView():New( 1, )
    oWebView:bOnBind = { | cJson, cCalls | ; //msginfo(cJson, cCalls) ,;
        hb_jsondecode( cJson, @hPost ), fromjavascirpt(hPost) ,   ;
            oWebView:Return( cCalls, 0, "{ 'result': '" + csend2js + "'  }" ) }
   
   
    oWebView:Bind( "SendToFWH" )
   
    oWebView:Navigate( "C:\fwh2023\samples\xguteanreise.html" )
    oWebView:SetTitle( "This is Fivewin 2024" )
    Sleep( 200 )
    fromjavascirpt(hPost)
    oWebView:RUN()
    oWebView:Destroy()
   
   
return nil


and at the moment the user is able to almost completly minimize it with the mouse.
here i send a picture to visualize it:
Image

thank you a lot in advance and have a nice day
ruth
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: TWebView window size

Postby Antonio Linares » Thu Feb 01, 2024 8:19 am

Dear Ruth,

good morning

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

function Main()

   local oWnd, oWebView

   DEFINE WINDOW oWnd TITLE "Using a webview from an existing window"

   oWnd:Center()
   oWnd:aMinMaxInfo = { 200, 200,;  // xMaxSize,      yMaxSize
                         50,  50,;  // xMaxPosition,  yMaxPosition
                         80,  80,;  // xMinTrackSize, yMinTrackSize
                        150, 150 }  // xMaxTrackSize, yMaxTrackSize

   oWebView = TWebView():New(, oWnd:hWnd )

   oWebView:Navigate( "http://www.google.com" )
   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" )

   ACTIVATE WINDOW oWnd CENTER ;
      ON RESIZE If( nWidth != nil, oWebView:SetSize( nWidth, nHeight ), oWebView:SetSize( 800, 500 ) )

   oWebView:Destroy()

return nil
regards, saludos

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

Re: TWebView window size

Postby Ruth » Thu Feb 01, 2024 9:57 am

Dear Antonio,

thank you so much for taking your time to answer.
I added the oWnd but now it seems that I no longer get all the responses as intended.
here is what intentionally happens without oWnd:

Image
and may I also share the code without oWnd ...
Code: Select all  Expand view

 #include "FiveWin.ch"
 static h := {=>}
 static csend2js := "send from Harbour"
 static oWebView
 
 function Main()
    local hPost := {}
   
    oWebView := TWebView():New( 1, )
    oWebView:bOnBind = { | cJson, cCalls | ; //msginfo(cJson, cCalls) ,;
        hb_jsondecode( cJson, @hPost ), fromjavascript(hPost) ,   ;
            oWebView:Return( cCalls, 0, "{ 'result': '" + csend2js + "'  }" ) }
   
   
    oWebView:Bind( "SendToFWH" )
   
    oWebView:Navigate( "C:\fwh2023\samples\xguteanreise.html" )
    oWebView:SetTitle( "This is Fivewin 2024" )
    Sleep( 200 )
    fromjavascript(hPost)
    oWebView:RUN()
    oWebView:Destroy()
   
   
return nil
//----------------------------------------------------------------------------//

function fromjavascript(hPost)
    local hTemp, aTemp
    local hTemp1
    local aParameters := {}
    local nIdx := 0
    local aNames := {}
   
    if len(hPost) > 0
        aParameters :=  hPost
       
        FOR nIdx := 1 to len( aParameters )
           
            //xoxo   xbrowse(   aParameters[ nIdx ]  )
        next
    endif
   
    if len(hPost)= 0
        oWebView:SetSize( 1260, 800 )
    else
       
         // Weitere Code-Logik
        // nur zum Testen
         aTemp := hPost[3]
        hTemp :=  aTemp['param1']
        hTemp1 :=  hTemp['additionalData']
       
        hTemp1['input4'] := "0" +  hTemp1['input4']
       
        hTemp1['input4'] :=  STRTRAN( hTemp1['input4'], ',', '.')
       
        USE (  "address" ) SHARED NEW
       
        APPEND BLANK
        address->name       :=   hTemp1['name']
       
        address->numIn4         :=   VAL( hTemp1['input4'] )
       
        //xoxo xbrowse( "address", )   
       
       
       
        h['response']  :=  '[{"id": "1", "first": "Mark", "last": "Otto", "handle": "@mdo"}, {"id": "2", "first": "Jacob222", "last": "Thornton", "handle": "@fat"}, {"id": "3", "first": "Larry", "last": "the Bird", "handle": "@twitter"}]'
       
        csend2js :=  h['response']
       
       
       
    endif
return nil
//----------------------------------------------------------------------------//

 


when I add oWnd unfortunately I don´t get a reaction anymore as expected when i click the ABFRAGE button.
I kindly ask for your help and take the opportunity to also share said code

Code: Select all  Expand view

 #include "FiveWin.ch"
 static h := {=>}
 static csend2js := "send from Harbour"
 static oWebView
 
 function Main()
    local hPost := {}
   
   
   
    local oWnd

   DEFINE WINDOW oWnd TITLE "Using a webview from an existing window"

   oWnd:Center()
   oWnd:aMinMaxInfo = { 1960, 1080,;  // xMaxSize,      yMaxSize
                         50,  50,;  // xMaxPosition,  yMaxPosition
                         80,  80,;  // xMinTrackSize, yMinTrackSize
                       1960, 1080 }  // xMaxTrackSize, yMaxTrackSize

   
   
     oWebView = TWebView():New(1, oWnd:hWnd )
   
    oWebView:bOnBind = { | cJson, cCalls | ; //msginfo(cJson, cCalls) ,;
        hb_jsondecode( cJson, @hPost ), fromjavascript(hPost) ,   ;
            oWebView:Return( cCalls, 0, "{ 'result': '" + csend2js + "' }" ) }
   
   
    oWebView:Bind( "SendToFWH" )
   
    oWebView:Navigate( "C:\fwh2023\samples\xguteanreise.html" )
     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:SetTitle( "This is Fivewin 2024" )
    Sleep( 200 )
    fromjavascript(hPost)
 
 
 
    ACTIVATE WINDOW oWnd CENTER ;
      ON RESIZE If( nWidth != nil, oWebView:SetSize( nWidth, nHeight ), oWebView:SetSize( 800, 500 ) )

   oWebView:Destroy()
 
 
 
 
  //  oWebView:RUN()
   
   
   
return nil
//----------------------------------------------------------------------------//

function fromjavascript(hPost)
    local hTemp, aTemp
    local hTemp1
    local aParameters := {}
    local nIdx := 0
    local aNames := {}
   
    if len(hPost) > 0
        aParameters :=  hPost
       
        FOR nIdx := 1 to len( aParameters )
           
            xbrowse(   aParameters[ nIdx ]  )
        next
    endif
   
    if len(hPost)= 0
      //  oWebView:SetSize( 1260, 800 )
    else
       
      msginfo("Fivewin")
       
       
        h['response']  :=  '[{"id": "1", "first": "Mark", "last": "Otto", "handle": "@mdo"}, {"id": "2", "first": "Jacob222", "last": "Thornton", "handle": "@fat"}, {"id": "3", "first": "Larry", "last": "the Bird", "handle": "@twitter"}]'
       
        csend2js :=  h['response']
       
       
       
    endif
return nil
//----------------------------------------------------------------------------//

 


please can you help me find the difference and help me correct my approach.
again kind regards and thank you in advance
ruth
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: TWebView window size

Postby Ruth » Thu Feb 01, 2024 11:21 am

dear antonio,
sorry...i forgot to add the xguteanreise.html code ...
here it is ... thank you again & kind regards ruth

Code: Select all  Expand view
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <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>
</head>

<body>
 
  <div class="container mt-3">
   
    <div class="row">
    <div class="col-lg-12">
      <h4 class="mt-4">CRM-Mails</h4>
    </div>
  </div>
   
         
            <div class="row">
              <div class="col-md-5">
               
                <!-- Abfrage auswählen -->
               
                <h2>Empfängerliste erstellen</h2>
                <div class="form-check form-check-inline">
                  <input type="radio" class="form-check-input" id="radio1" name="optradio" value="option1" checked>alle
                  <label class="form-check-label" for="radio1"></label>
                </div>
                <div class="form-check form-check-inline">
                  <br><input type="radio" class="form-check-input " id="radio2" name="optradio" value="option2">nur markierte Buchungen
                  <label class="form-check-label" for="radio2"></label>
                </div>
                <br>
                <hr>
                <br>
                <label for="sel1" class="form-label">Mailing auswählen:</label>
                <select class="form-select" id="sel1" name="sellist1">
                 
                  <option>Gute Anreise</option>
                  <option>Danke</option>
                  <option>Nachfassen Angebot</option>
                </select>
                <br>
                <hr>
                <br>
               
               
               
               
                <label for="sel2" class="form-label">Zeitraum eingeben:</label>
                <select class="form-select" id="sel2" name="sellist2">
                  <option>1</option>
                  <option>2</option>
                  <option>3</option>
                  <option>4</option>
                </select>
                <br>
                <hr>
                <br>
               
                <button id="edit-btn" class="btn btn-outline-success btn-lg" >Abfrage</button>
               
              </div>
              <div class="col-md-7">
               
               
                <h2>Empfängerliste</h2>
               
                <table class="table">
                  <thead>
                    <tr>
                      <th scope="col">#</th>
                      <th scope="col">First</th>
                      <th scope="col">Last</th>
                      <th scope="col">Handle</th>
                    </tr>
                  </thead>
                  <tbody id="tableBody">
                  </tbody>
                </table>
               
               
                <br>
                <hr>
                <br>
                <h2>Treffer gesammelt nach</h2>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled">
                  <label class="form-check-label" for="flexRadioDisabled">
                    DEUTSCH SIE
                  </label>
                </div>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled">
                  <label class="form-check-label" for="flexRadioDisabled">
                    DEUTSCH DU
                  </label>
                </div>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled">
                  <label class="form-check-label" for="flexRadioDisabled">
                    ENGLISCH SIE
                  </label>
                </div>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled" >
                  <label class="form-check-label" for="flexRadioDisabled">
                    ENGLISCH DU
                  </label>
                </div>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled">
                  <label class="form-check-label" for="flexRadioDisabled">
                    ITALIENISCH SIE
                  </label>
                </div>
               
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled" >
                  <label class="form-check-label" for="flexRadioDisabled">
                    ITALIENISCH DU
                  </label>
                </div>
               
               
                <br>
                <hr>
                <br>
               
               
                <button type="submit" class="btn btn-primary mt-3">Briefauswahl öffnen und Email abschicken</button>
              </div>
            </div>
           
          </div>
        </div>
     
 
 
  <script>
   
    document.getElementById('edit-btn').addEventListener('click', editbtn);
   
   
   
   
   
   
    function editbtn(evt) {
      var formData = {
        name: 'name',
        input4: 'input'
      };
     
      const data = {
        text: 'editbtn button clicked',
        btn: 'anfrageformular',
        additionalData: formData
      };
      var someData = { 'param1': data };
      var s = SendToFWH(evt.target.id, evt.type, someData)
      .then(s => {
        const jsonString = s.result;
       
        console.log('Type:', typeof jsonString);
        console.log('Length:', jsonString.length);
        console.log('Content:', jsonString);
       
        const resultArray = JSON.parse(jsonString);
        const resultObject = JSON.parse(s.result);
        console.log(resultObject);
       
        const tableBody = document.getElementById("tableBody");
       
        resultArray.forEach(item => {
          const row = tableBody.insertRow();
          Object.keys(item).forEach((key, index) => {
            const cell = row.insertCell(index);
            cell.textContent = item[key];
          });
        });
      });
    }
   
   
   
   
  </script>
 
 
</body>
</html>
 
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: TWebView window size

Postby Antonio Linares » Thu Feb 01, 2024 4:57 pm

Dear Ruth,

Could you please email me address.dbf ? thanks

If we don't make TWebView child of a parent window, then we can not control the size of it.
regards, saludos

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

Re: TWebView window size

Postby Ruth » Fri Feb 02, 2024 7:32 am

Dear Antonio,

may I also post this additional code our team has made for this project:

Code: Select all  Expand view
CheckTables()


function CheckTables()

   if ! File(   "address.dbf" )
      DbCreate( "address.dbf",;
         {      {"name", "C", 100, 0 },;
                               {"firstNm", "C", 100, 0 },;
                               {"street", "C", 100, 0 },;
                               {"postCode", "C", 100, 0 },;
                               {"ctryCode", "C", 100, 0 },;
                               {"city", "C", 100, 0 },;
                               {"numIn1", "N", 10, 2 },;
                               {"numIn2", "N", 10, 2 },;
                               {"numIn3", "N", 10, 2 },;
                               {"numIn4", "N", 10, 2 } } )
   endif

return nil
//----------------------------------------------------------------------------//
 


thank you very much for taking your time and caring about this.
kind regards
Ruth
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: TWebView window size

Postby Antonio Linares » Fri Feb 02, 2024 11:36 am

I am thinking about using a thread to run webview, so both events loops (FWH and WebView) may coexist...

An example coming soon :-)
regards, saludos

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

Re: TWebView window size

Postby Ruth » Fri Feb 02, 2024 7:22 pm

thank you so much, dear Antonio.
We are so happy that you are helping us with this and are looking forward very much to the coexistence :-)
kind regards and a nice evening to you
Ruth
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: TWebView window size

Postby Antonio Linares » Sat Feb 03, 2024 8:49 am

Dear Ruth,

Here you have it working thanks to Charles KWON charleskwonohjun@gmail.com help and some changes from me:
Code: Select all  Expand view
#include "FiveWin.ch"

static h := {=>}
static csend2js := "send from Harbour"
static oWebView
static oTimer

// Modified by Charles KWON ( charleskwonohjun@gmail.com )

function Main()

   local oDlg
 
   DEFINE DIALOG oDlg

   ACTIVATE DIALOG oDlg CENTERED ;      
      ON INIT OnInit( oDlg ) ;
      VALID ( oWebView:Terminate(), oWebView:Destroy(), .T. )

return nil

static function OnInit( oDlg )

    local hPost := {}

    oWebView := TWebView():New( , oDlg:hWnd )

    oWebView:bOnBind = { | cJson, cCalls | ;
       hb_jsondecode( cJson, @hPost ), fromjavascript(hPost) ,   ;
       oWebView:Return( cCalls, 0, "{ 'result': '" + csend2js + "'  }" ) }
   
    oWebView:SetSize( 1400, 1400 )
    oDlg:Center()
    oWebView:Bind( "SendToFWH" )
    oWebView:Navigate( "C:\fwh2023\samples\xguteanreise.html" )      
    SetForeGroundWindow( oDlg:hWnd )
    oWebView:SetTitle( "This is Fivewin 2024" )    
    oWebView:Run()

return nil

function fromjavascript(hPost)
   local hTemp, aTemp
   local hTemp1
   local aParameters := {}
   local nIdx := 0
   local aNames := {}
 
   if len(hPost) > 0
       aParameters :=  hPost
     
       FOR nIdx := 1 to len( aParameters )
           // xbrowse(   aParameters[ nIdx ]  )
       next
   endif
 
   if len(hPost)= 0
       oWebView:SetSize( 1260, 800 )
   else
     
        // Weitere Code-Logik
       // nur zum Testen
        aTemp := hPost[3]
       hTemp :=  aTemp['param1']
       hTemp1 :=  hTemp['additionalData']
     
       hTemp1['input4'] := "0" +  hTemp1['input4']
     
       hTemp1['input4'] :=  STRTRAN( hTemp1['input4'], ',', '.')
     
       USE (  "address" ) SHARED NEW
     
       APPEND BLANK
       address->name       :=   hTemp1['name']
     
       address->numIn4         :=   VAL( hTemp1['input4'] )

       dbCloseArea()  // bugfix By Charles KWON
     
       //xoxo xbrowse( "address", )  
     
       h['response']  :=  '[{"id": "1", "first": "Mark", "last": "Otto", "handle": "@mdo"}, {"id": "2", "first": "Jacob222", "last": "Thornton", "handle": "@fat"}, {"id": "3", "first": "Larry", "last": "the Bird", "handle": "@twitter"}]'
     
       csend2js :=  h['response']
   endif

return nil
//----------------------------------------------------------------------------//
regards, saludos

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

Re: TWebView window size

Postby Antonio Linares » Sat Feb 03, 2024 9:07 am

We have implemented two new METHODs in Class TWebView:

METHOD End() INLINE ( ::Terminate(), ::Destroy() )

and

METHOD hWnd() INLINE ::GetWindow()

they will be available in next FWH build

So the code can be simplified this way:
Code: Select all  Expand view
  ACTIVATE DIALOG oDlg CENTERED ;      
      ON INIT OnInit( oDlg ) ;
      VALID ( oWebView:End(), .T. )
regards, saludos

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

Re: TWebView window size

Postby Ruth » Sat Feb 03, 2024 4:54 pm

Oh, this is wonderful, dear Antonio and dear Mr. Kwon. THANK YOU so very much!!! :-)
We are very, very happy to have this. Kind regards to you and have a nice weekend
Ruth
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: TWebView window size

Postby Otto » Sun Feb 04, 2024 12:38 am

Dear Antonio,

Thank you so much.

I conducted a test with two oSay elements. Everything is working fine except for the destroy method.

Best regards,
Otto


Here is my test code:
wv_say.prg

Code: Select all  Expand view

#include "FiveWin.ch"
#include "Splitter.ch"

static oWnd
static h := {=>}
static csend2js := "send from Harbour"
static oWebView, oWebView2

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

function Main()
   local oDlg, oSay1, oSay2, lExit := .f., oBtn
    start_sample()
   DEFINE DIALOG oDlg FROM 5, 5 TO 55, 180 TITLE "A Dialog Box"

    @ 10,10 ;
         SAY oSay1 ;
      PROMPT "oSay1" ;
       PIXEL ;
        SIZE 300, 300

    @ 10,380 ;
         SAY oSay2 ;
      PROMPT "Osay2" ;
       PIXEL ;
        SIZE 300, 300

   @ 20,   4 BUTTON "&Say" OF oDlg SIZE 40, 12 ACTION  webshow( 1, oSay1:hWnd,1)
   @ 20,  14 BUTTON "&Say1" OF oDlg SIZE 40, 12 ACTION  webshow2( 1, oSay2:hWnd,2)

   @ 20, 60 BUTTON oBtn PROMPT "&Cancel" OF oDlg SIZE 40, 12   ACTION oDlg:END()


   ACTIVATE DIALOG oDlg    ;
      VALID ( oWebView:Destroy(), oWebView2:Destroy(),.T. )

return nil

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

function webshow(console,hWnd, nlink)
   local hPost := {}
   local cHtmlOrUrl :=  "C:\fwh2023\samples\address.html"

   oWebView := TWebView():New( , hWnd )
   oWebView:bOnBind = { | cJson, cCalls | ;
      hb_jsondecode( cJson, @hPost ), fromjavascript(hPost) ,   ;
      oWebView:Return( cCalls, 0, "{ 'result': '" + csend2js + "'  }" ) }

   oWebView:Bind( "SendToFWH" )
   oWebView:Navigate( cHtmlOrUrl  )
   oWebView:SetTitle( "This is Fivewin 2024" )
   oWebView:Run()

return oWebView

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

function webshow2(console,hWnd, nlink)
   local hPost := {}
   local cHtmlOrUrl := "C:\fwh2023\samples\address.html"

   oWebView2 := TWebView():New(1 , hWnd )

   oWebView2:bOnBind = { | cJson, cCalls | ;
      hb_jsondecode( cJson, @hPost ), fromjavascript(hPost) ,   ;
      oWebView2:Return( cCalls, 0, "{ 'result': '" + csend2js + "'  }" ) }

   oWebView2:Bind( "SendToFWH" )
   oWebView2:Navigate( cHtmlOrUrl  )
   oWebView2:SetTitle( "This is Fivewin 2024" )
   oWebView2:Run()

return oWebView2

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

function fromjavascript(hPost)
   local hTemp, aTemp
   local hTemp1
   local aParameters := {}
   local nIdx := 0
   local aNames := {}

   if len(hPost) > 0
      aParameters :=  hPost
      // xbrowse(hPost)
      FOR nIdx := 1 to len( aParameters )
         //    xbrowse(   aParameters[ nIdx ]  )
      next
   endif

   if len(hPost)= 0
      //      oWebView:SetSize( 1260, 800 )
   else

      aTemp := hPost[3]
      hTemp :=  aTemp['param1']

      USE (  "address" ) SHARED NEW
      APPEND BLANK
      address->name       :=   hTemp['name']
      address->street         :=     hTemp['street']
      address->city :=  hTemp['city']

      h['response']  := "["
      select address
      go top
      do while .not. eof()
         h['response']  += "{" + '"name":' + '"' + ALLTRIM( address->name ) + '",'
         h['response']  += '"street":' +  '"' + ALLTRIM( address->street ) +  '",'
         h['response']  +=  '"city":' +  '"' + ALLTRIM( address->city ) +  '" },'
         skip
      enddo
      h['response'] := left( h['response'] , len(h['response'] )-1 ) + "]"
      dbCloseArea()

   
      csend2js :=  h['response']
   endif

return nil
//----------------------------------------------------------------------------//

FUNCTION  start_sample()
 
CheckTables()

return nil
//----------------------------------------------------------------------------//

function CheckTables()

   if ! File(   "address.dbf" )
      DbCreate( "address.dbf",;
         {  {"name", "C", 100, 0 },;
                {"firstNm", "C", 100, 0 },;
                {"street", "C", 100, 0 },;
                {"postCode", "C", 100, 0 },;
                {"ctryCode", "C", 100, 0 },;
                {"city", "C", 100, 0 },;
                {"numIn1", "N", 10, 2 },;
                {"numIn2", "N", 10, 2 },;
                {"numIn3", "N", 10, 2 },;
                {"numIn4", "N", 10, 2 } } )
   endif

return nil

 


and the HTML code.
address.html
Code: Select all  Expand view

<!DOCTYPE html>
<html lang="de">
<head>
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <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>
  </head>
  <body>
   
    <div class="container mt-5">
      <div class="mb-3">
        <label for="name" class="form-label">Name</label>
        <input type="text" class="form-control" id="name" >
      </div>
      <div class="mb-3">
        <label for="street" class="form-label">Straße</label>
        <input type="text" class="form-control" id="street" >
      </div>
      <div class="mb-3">
        <label for="city" class="form-label">Ort</label>
        <input type="text" class="form-control" id="city" >
      </div>
      <button id="edit-btn" class="btn btn-outline-success" >Abfrage</button>
   
    <!-- Tabelle -->
    <table class="table mt-3">
      <thead>
        <tr>
          <th scope="col">name</th>
          <th scope="col">street</th>
          <th scope="col">city</th>
        </tr>
      </thead>
      <tbody id="tableBody">
        <!-- Zeilen werden hier über JavaScript hinzugefügt -->
      </tbody>
    </table>
  </div>
 
  <!-- JavaScript Logik -->
  <script>
    document.getElementById('edit-btn').addEventListener('click', editbtn);
   
    function editbtn(evt) {
      var name = document.getElementById('name').value
      var street =document.getElementById('street').value
      var city =document.getElementById('city').value
      const data = {
        text: 'editbtn button clicked',
        name: name,
        street: street,
        city: city,
        btn: 'anfrageformular'
      };
      var someData = { 'param1': data };
      var s = SendToFWH(evt.target.id, evt.type, someData)
      .then(s => {
        const jsonString = s.result;
      //  alert(jsonString);  
        console.log('Type:', typeof jsonString);
        console.log('Length:', jsonString.length);
        console.log('Content:', jsonString);
       
        const resultArray = JSON.parse(jsonString);
        const resultObject = JSON.parse(s.result);
        console.log(resultObject);
       
        const tableBody = document.getElementById("tableBody");
       
        resultArray.forEach(item => {
          const row = tableBody.insertRow();
          Object.keys(item).forEach((key, index) => {
            const cell = row.insertCell(index);
            cell.textContent = item[key];
          });
        });
      });
    }
 
</script>

</body>
</html>



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

Re: TWebView window size

Postby Antonio Linares » Sun Feb 04, 2024 9:16 am

Dear Otto,

Please change this line this way:
Code: Select all  Expand view
  ACTIVATE DIALOG oDlg    ;
      VALID ( oWebView:Terminate(), oWebView:Destroy(), oWebView2:Terminate(), oWebView2:Destroy(), .T. )

We have added a new METHOD End() that simplifies it:
Code: Select all  Expand view
  ACTIVATE DIALOG oDlg    ;
      VALID ( oWebView:End(), oWebView2:End(), .T. )

In Class TWebView please addd this:
Code: Select all  Expand view
METHOD End() INLINE ( ::Terminate(), ::Destroy() )
regards, saludos

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

Re: TWebView window size

Postby Otto » Sun Feb 04, 2024 2:53 pm

Dear Antonio,
thank you, it works well.

This Webview2 is incredible. It opens up so many possibilities. One doesn't even know where to start.
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: 6301
Joined: Fri Oct 07, 2005 7:07 pm

Re: TWebView window size

Postby Antonio Linares » Sun Feb 04, 2024 4:16 pm

We are working to simplify it and use it the FWH way...

Stay tuned for new examples coming very soon :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

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