HtmlPanel - rich text on the device

Discussion in 'Additional Libraries' started by agraham, Mar 2, 2009.

  1. agraham

    agraham Expert Licensed User

    It has long been a problem that a RichTextBox has not been available on devices so that producing coloured and formatted text has been a problem. The only work around for Basic4ppc has been to use a WebBrowser but that is not always ideal.

    I have looked around many times but have not found a non-commercial solution but at long last I have stumbled upon some code written in the early days of .NET 1.0 that is worth building upon.

    This is very much an initial taster version. I have a lot more work to do to expose more functionality but note that you should be able to assign a ContextMenu to it so overcoming one of the WebBrowser shortcomings. Suggestions for improvement are welcome.

    No manual yet but demo included. It should work on .NET 1.0 and later on both device and desktop.

    EDIT: Improved version 0.2 posted.

    EDIT: Version 1.0 posted with help and demo. See post #13.

    EDIT: Version 1.1 posted. See post #16.

    EDIT: Version 1.2 posted. See post #20.

    EDIT: Version 1.3 posted. See post #21.

    EDIT: Version 1.4 posted. This version is AutoScale aware. See post #30.

    EDIT: Version 1.5 posted. See post #48.
     

    Attached Files:

    Last edited: Aug 21, 2009
  2. Byak@

    Byak@ Active Member Licensed User

    wow!big thanks agraham!it is very good!
    but maybe it's real with this control-
    1)selecting text(and params selectStart and select Length)
    2)scroll this control for comand(for example pageup,pagedown)
    3)place event mouseup/down/move to this control
    4)know position of scrollbar
     
  3. agraham

    agraham Expert Licensed User

    It isn't possible to select text using the mouse. The demo shows that you can detect the block of text that was clicked but that's as close as you will get to selecting text.
    The scrollbar LargeChange properties give you the value in pixels for a page distance.
    Mouse and ScrollBar events added.
    Get and set ScrollBar values added together with Max value which is the length in pixels of the rendered bitmap
     
  4. Byak@

    Byak@ Active Member Licensed User

    thanks agraham)but maybe it is real to add selecting text? or another way for it?
     
  5. agraham

    agraham Expert Licensed User

    I think it's about time we sorted out what you mean by "is it real" as you use it a lot but I don't know really what you mean :confused: Do you mean "is it possible" or "does it exist"?
     
  6. Byak@

    Byak@ Active Member Licensed User

    in this case "does it exist" =)
     
  7. moster67

    moster67 Expert Licensed User

    Graham,

    Great stuff by you as usual. You're my hero ! I will look forward to following the progress of this control.

    I read somewhere that a few years (versions back) ago, Microsoft actually released a RichTextBox for Windows Mobile in a beta-release of VS (or CF.NET) but it was later abandoned.

    rgds,
    moster67
     
  8. N1c0_ds

    N1c0_ds Active Member Licensed User

    It might just be me, but I think there is a problem at display. There is a ~13 pixels wide space (scrollbar space?) where no text is displayed. This means there is sometimes a missing letter at the end of the panel.
     
  9. agraham

    agraham Expert Licensed User

    It is the scrollbar space but that's not why you are missing characters. It is presently riddled with obscure bugs, hence the 0.x versioning and lack of help. I'm wringing them out at the moment. Next version in a day or so.
     
  10. N1c0_ds

    N1c0_ds Active Member Licensed User

    Great! Looking forward to include it in Gecko ^_^
     
  11. tcmdvm

    tcmdvm New Member Licensed User

    Problem with " and '

    This doesn't work:
    HtmlPanel.HTML = "<html name='myform'>This is a line <font color="yellow">of colored text </font>I hope it was yellow.</html>"

    This works:
    HtmlPanel.HTML = "<html name='myform'>This is a line <font color='yellow'>of colored text </font>I hope it was yellow.</html>"

    This doesn't work:
    HtmlPanel.Html = "<html name=''><b> This is some text.</b> <i> (and more text,</i> and <i> more text).</i> <a href="My_Text">My Text</a></html>"

    This works:
    HtmlPanel.Html = "<html name=''><b> This is some text.</b> <i> (and more text,</i> and <i> more text).</i> <a href='My_Text'>My Text</a></html>"

    In both cases I replaced the double quotes with a single quote.

    Am I missing something in the html code or is this a bug?
     
  12. agraham

    agraham Expert Licensed User

    Neither, you are overlooking that Basic4ppc delimits strings with double quotes. I would guess that you are running in the IDE which has a benign outlook on string format errors. If you optimised compiled it you would find that the much stricter compiler will complain.

    Effectively your lines that don't work are interpreted by Basic4ppc as

    HtmlPanel.HTML = "<html name='myform'>This is a line <font color=" & yellow & ">of colored text </font>I hope it was yellow.</html>"

    As the variable yellow is probably empty I would guess your text is being drawn in Black. If you want to embed double quotes in a Basic4ppc string then use

    HtmlPanel.HTML = "..color =" & Chr(34) & "yellow" & Chr(34) & ">of colo...."

    It's easier to stick to single quotes in code!
     
  13. agraham

    agraham Expert Licensed User

    The first "real" version is now posted with help file and demo. No source for merging as this is a multi-file VS2005 project and I am not going to try to pack it all into one file until I am a lot happier that it is getting to nearly a final version.

    I am thinking of adding <UL> and that will be all for the time being unless anyone has any other suggestions.
     
  14. tcmdvm

    tcmdvm New Member Licensed User

    Missing help file

    I downloaded the new version but it seems the help file is missing.

    It works much better than the initial version.

    However, without a help file its hard to know what all of the properties do.
     
  15. agraham

    agraham Expert Licensed User

    Sorry, finger trouble omitted the help from the archive, now added. Please download again.
     
  16. agraham

    agraham Expert Licensed User

    Version 1.1 has some bugs fixed.

    Break, <BR>, is improved to behave as you (or at least I) expect.

    Strikeout, <S>, vertical position, <VP> and list, <UL> and <LI> tags added.
     
  17. agraham

    agraham Expert Licensed User

    I would think so. It has no connection with the WebBrowser, all the layout and linking and event management is done by my own code so I can modify it if needed.

    It does work on WM2003, I've tested it. Unless anyone comes up with suggestions or bugs the feature set is complete and I regard the code as stable. Use it by all means, any future versions should be backward compatible with this version, which was not the case before version 1.1.
     
  18. agraham

    agraham Expert Licensed User

    Version 1.2 posted. I was playing with this library and found a couple of minor layout bugs and thought that it might be nice to allow text to be drawn alongside images. While you can't flow text around images you can now position multiple lines of text next to an image positioned at the left or right of the page. EDIT: Or even text between two images at the left and right of the page.

    The changes are -

    A UTF8 file preceded by a BOM (Byte Order Mark), as produced by Notepad for example, is now accepted without error.

    The <VP> offset attribute value now applies to an image in addition to its' new vspace attribute value

    The <UL> tag now has a start attribute to define the initial value of a numeric or alpha bullet.

    The <LEFT> tag is added to support a margin attribute to allow extra margin at the right of text for an image.

    The <RIGHT> and <CENTER> tags now have a margin attribute to allow extra margin at the left of right justified text and both sides of centred text.

    The <IMG> tag has seven new attributes hspace, vspace, border, color, width, height and ignore. These provide more flexibility for image display.
     
    Last edited: Mar 15, 2009
  19. agraham

    agraham Expert Licensed User

    Yet another improved version 1.3 posted. Document navigation was the focus for this version but other "stuff" crept in along the way :).

    User navigation may now be cancelled, like in the WeBrowser, by a CancelNavigate property. Program control of navigation can jump to a link destination, the last point the user clicked or to any arbitrary X-Y position in the document. The last user clicked coordinates are available as properties so that a multiple "undo" can be provided if required.

    XML errors are now more easily located. Previously to the XML parser the source looked like one long line so XML errors always occurred on line 1! Now the correct line numbers are reported.

    Mouse down events are now raised when an "ignore='true'" image is clicked. <IMG> and <HR> now support the Name attribute so that the actual element clicked may be identified. A new ClickedItemName property returns the name of the element clicked.

    <A> tags nows support Underline and Color properties so that individual links may be easily customised.

    Support for borders is improved. <FONT> now has Border and BorderColor attributes. <LEFT>, <CENTER> and <RIGHT> now have Border and Bordercolor attributes and for convenience also have Color and Bgcolor. <IMG> now has Bordercolor to be used instead of the previous Color for consistency.

    The default values for various attributes are changed for consistency, mainly more are inherited than before. The attribute defaults are documented in the help.
     
  20. agraham

    agraham Expert Licensed User

    Not at the moment though you could guess from the various coordinates returned and assuming a fixed width font.
     
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