Help with HTML panel

Discussion in 'Questions (Windows Mobile)' started by derez, May 25, 2009.

  1. derez

    derez Expert Licensed User

    I found the HTML panel library and it seems exact to upgrade my chat program, but...
    I don't understand the HTML language and the help file just adds to my confusion.

    Can someone tell me how to do the following:

    write a string on the panel, each separate string in one of few predefined formats (e.g. - font size and text color).

    The strings are created in real time so I cannot use preset HTML files for them.

    As strings are written, the panel should scroll down to show the last string written.

    Thanks.
     
  2. derez

    derez Expert Licensed User

    thank you for the elaborated explanation and example.
    I'll study it.:)

    Edit:
    The code is what I took from the example, to demonstrate what I wanted.
    It still lacks the automatic scroll down after each input - I can't do it.
    the form has a textbox and a button.

    Code:
    Sub Globals
       
    Dim myPageText
       k = 
    1
    End Sub

    Sub App_Start
       Form1.Show   
       HtmlPanel.New1(
    "Form1"00,220,200)
       HtmlPanel.ButtonColor = cWhite
       HtmlPanel.ScrollBarWidth = 
    10
       HtmlPanel.RenderWidth = 
    210
    End Sub


    Sub Button1_Click
    k = -
    1 * k
    st =  tb.Text
    If k = 1 Then
       myPageText = myPageText & 
    "<font color='red'>" & st & "</font><br />"
    Else
        myPageText = myPageText & 
    "<font color='green'>" & st & "</font><br />"
    End If
    HtmlPanel.ShowHtml (
    "<html><body>" & myPageText & "</body></html>")
    tb.Text = 
    ""
    End Sub
     
    Last edited: May 26, 2009
  3. agraham

    agraham Expert Licensed User

    Try
    Code:
    HtmlPanel.VScrollValue = HtmlPanel.VScrollMax - HtmlPanel.VScrollLargeChange + 1
     
  4. derez

    derez Expert Licensed User

    Thanks Andrew, it works now.

    The problem was the missing +1 at the end, see the help:

    "VScrollValue : Int32 [I/O] : Gets or sets the position of the vertical scrollbar. The minimum to use is 0 and the maximum is VScrollMax - VScrollLargeChange otherwise the underlying Panel will become visible."
     
  5. agraham

    agraham Expert Licensed User

    I'm surprised, the +1 is a nicety that avoids a final 1 pixel movement of the the panel if you press the scroll bar down button. The difference is hardly visible so it should have scrolled to the bottom without it :confused:
     
  6. derez

    derez Expert Licensed User

    If I remove the +1 I get this error.
     

    Attached Files:

  7. agraham

    agraham Expert Licensed User

    That's probably because you haven't got enough text yet to actually need scrolling to view the last so VScrollLargeCHange is less than VScrollMax. Production code should probably include a test for negative for the scroll value.
     
  8. derez

    derez Expert Licensed User

    I used the panel in the Chat program, here are screen views of the way text is formatted according to the message source.
    Also - I attach a sub to show how I change the color of the last line (I do it to signal the reception of the message by the other side)

    both last and myPageText are globals.

    Code:
    Sub write_line(st,source)
    Select source 
        
    Case "R"   ' Remote message
           last = "<font color='blue' size='12'>" & st & "</font><br />"
          myPageText = myPageText & last
       
    Case "L"   ' Local message
           st = StrReplace(st,Chr(0),"")  'remove hebrew device control charachter 
           last = "<font color='black' size='10'> " & st & "</font><br />"
          myPageText = myPageText & last
       
    Case "M"    ' Machine message
           last = "<font color='red' size='12'>" & st & "</font><br />"
          myPageText = myPageText & last
    End Select
    HtmlPanel.ShowHtml (
    "<html><body>" & myPageText & "</body></html>")
    HtmlPanel.VScrollValue = HtmlPanel.VScrollMax - HtmlPanel.VScrollLargeChange + 
    1
    End Sub

    Sub change_color
    myPageText = StrReplace(myPageText,last,
    "")
    last = StrReplace(last,
    "color='black'","color='green'")
    myPageText = myPageText  & last
    HtmlPanel.ShowHtml (
    "<html><body>" & myPageText & "</body></html>")
    End Sub
    Thanks to Badkarma and Agraham :)
     
  9. derez

    derez Expert Licensed User

    But the colored keyboard is the only thing I didn't do ....
     
  10. derez

    derez Expert Licensed User

    It comes as part of the Hebrew language package which is installed on my device.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice