HtmlPanel - rich text on the device

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.
 

Attachments

Last edited:

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
 

agraham

Expert
Licensed User
selecting text(and params selectStart and select Length)
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.
scroll this control for comand(for example pageup,pagedown)
The scrollbar LargeChange properties give you the value in pixels for a page distance.
place event mouseup/down/move to this control
Mouse and ScrollBar events added.
know position of scrollbar
Get and set ScrollBar values added together with Max value which is the length in pixels of the rendered bitmap
 

Byak@

Active Member
Licensed User
thanks agraham)but maybe it is real to add selecting text? or another way for it?
 

Byak@

Active Member
Licensed User
in this case "does it exist" =)
 

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
 

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.
 

N1c0_ds

Active Member
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.
Great! Looking forward to include it in Gecko ^_^
 

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?
 

agraham

Expert
Licensed User
Am I missing something in the html code or is this a bug?
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!
 

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.
 

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.
 

agraham

Expert
Licensed User
Could this get around the WM2003 O/S unsupported hyperlink issues I experienced with WebBrowser
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.

If HTMLPanel will work on WM2003, and once your final version is ready, are you OK with me using it with my app Adventure PDA?
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.
 

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:

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.
 
Top