Results 1 to 2 of 2

Thread: Html gui (text box)

  1. #1

    Html gui (text box)

    this is based on WebBrowser_02.tbasic example
    the text box in html can hold huge data such as 1000004 characters string
    the text box here is encoded in
    <textarea id="TEXTBOX" rows="25" cols="60">
    we can add text between
    <textarea id="TEXTBOX" rows="25" cols="60">
    ....text is here....
    </textarea>

    we can get or set text using the textarea id and here it is "TEXTBOX" you can also use your cat name.
    click 'OK' button to add 1000004 characters to the text area.
    and to get again the text and add to it 'OK' and save it to the file "test.txt"

    don't use msgbox, it can't handle big data, and sometimes it cause the thinbasic.exe stay in memory. look the original example WebBrowser_02.tbasic , something needs correction.
    also the Console can't hold more than a few thousands of chars (this is normal). so the text box in the web browser is too good .

    put the attached test.html file in the same folder as the code:
      '------------------------------------------------------------------
      ' Pre-processor prerequisites
      '------------------------------------------------------------------
      #minversion 1.7.8.0
      
      '------------------------------------------------------------------
      ' Declare needed thinBasic modules
      '------------------------------------------------------------------
      USES "UI"
      Uses "UIAdv"
      Uses "Console" 
      Uses "File"
      
      Global LargeData As String
      LargeData = String$(1000000, "A")
      LargeData = LargeData + "_ ZZZ"
      
      '------------------------------------------------------------------
      ' Global declarations
      '------------------------------------------------------------------
        begin const
          %ID_WEB1           = 200
          %ID_OK
          
        end const
    
      '------------------------------------------------------------------
      ' Main script entry point
      '------------------------------------------------------------------
      function TBMain() as long
        local hDlg    AS LONG
        local Count   as long
        
        '---Create a new window
        DIALOG NEW pixels, 0, "Web Browser control test", _
                                            -1, -1, 640, 500, _
                                            %WS_CLIPCHILDREN      or _
                                            %WS_CLIPSIBLINGS      or _
                                            %WS_DLGFRAME          OR _
                                            %DS_CENTER            OR _
                                            %WS_CAPTION           OR _
                                            %WS_SYSMENU           OR _
                                            %WS_OVERLAPPEDWINDOW  ,  _
                                            0 _
                                            TO hDlg
    
        '---Show new window and assign it callback function
        DIALOG SHOW MODELESS hDlg, call cbDialog_Proc
        Do
          DIALOG DOEVENTS 0 To Count
        Loop While Count
    
      end function
    
      '------------------------------------------------------------------
      ' Window callback handle. Use to handle message pump of main window
      '------------------------------------------------------------------
      callback function cbDialog_Proc() as long
        Local sBuffer As String
        local lValue  as long
            
        SELECT CASE cbMsg
          
          CASE %WM_INITDIALOG
     
            WebBrowser_Create CBHNDL, %ID_WEB1, "", 20, 20, 620, 430, %WS_CHILD Or %WS_VISIBLE, 0
            WebBrowser_Navigate2(CBHNDL, %ID_WEB1, "file://" & APP_SourcePath & "test.html")
            control set resize cbhndl, %ID_WEB1, 1, 1, 1, 1
    
            Control Add Button CBHNDL, %ID_OK, "OK", 580, 460, 50, 40
            Control Set Resize CBHNDL, %ID_OK, 0, 1, 0, 1
                    
          case %WM_DESTROY
            
          case %WM_COMMAND
            select case cbctl
              Case %ID_OK
                sBuffer = ""
                sBuffer += $CRLF & "Data: " & WebBrowser_Doc2_GetElementInnerHtmlById(CBHNDL, %ID_WEB1, "TEXTBOX")
                WebBrowser_Doc2_SetElementInnerHtmlById (CBHNDL, %ID_WEB1, "TEXTBOX", LargeData)
                sBuffer = WebBrowser_Doc2_GetElementInnerHtmlById(CBHNDL, %ID_WEB1, "TEXTBOX")
                sBuffer = sBuffer + " OK"
                FILE_Save("test.txt", sBuffer) 
                'MsgBox 0, sBuffer ' not good
                PrintL sBuffer ' does not display too much chars
                
            end select
        END SELECT
    
      end function
    

    test.html file:
    <!DOCTYPE html>
    <html>
    <body>
    
    <textarea id="TEXTBOX" rows="25" cols="60">
    Hello World, Hello World, Hello World, Hello World, Hello World, Hello World, 
    </textarea>
    
    </body>
    </html>
    
    Attached Files Attached Files
    Last edited by primo; 07-08-2018 at 17:15.

  2. #2
    nice example

Similar Threads

  1. HTML 5 Demos
    By kryton9 in forum Shout Box Area
    Replies: 3
    Last Post: 29-05-2009, 02:04
  2. HTML help for TBGL?
    By Intio in forum TBGL module by Petr Schreiber
    Replies: 8
    Last Post: 19-12-2008, 16:48

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •