HTML Recognized by the MessageBox

Top  Previous  Next

All HTML tags and attribute names in the HTML recognized by the HTML MessageBox are case-insensitive.

 

Tags:

 

The following tags are recognized:

 

<B>...</B>, to make the enclosed text bold
<I>...</I>, to make the enclosed text italic
<U>...</U>, to make the enclosed text underlined
<FONT SIZE=pointSize FACE=fontName COLOR=nameOrValue>...</FONT>, to set the font for the enclosed text.
<BR>, for a line break (may be replaced with newline, ASCII 10, or carriage return followed by newline, if the function HtmlMessageBoxSetNewlineIsBreak(1) has been called).
N.B. neither <BR/> nor <BR />, which modern HTML often uses, are recognized!

 

Closing tags are never required - if a tag is not closed, its meaning extends to the end of the text. Nesting is not implemented, so for instance if a 2nd <FONT> tag appears before a first one has been closed, it completely replaces the meaning of the first one (including default attribute values), rather than adding to its meaning as in standard HTML.

 

FONT Tag Attributes:

 

The following are the attributes of the FONT tag. All are optional, and case-insensitive. The attribute values can be quoted with double quotes, or unquoted (though the FONT FACE name must be quoted if it contains spaces). Spaces are not allowed around the equal sign in an attribute.

 

SIZE: a size in points. (This is different from standard HTML, where sizes are a range from 1 to 6.) The default size, if no <FONT> tag is in effect, or the SIZE attribute is omitted from a FONT tag, is 10. However, that default can be changed by calling the HtmlMessageBoxSetDefaultPointSize(points) function.
FACE (or FAMILY): The name of a font face, such as Arial or "Times New Roman". Unlike standard HTML, a comma-separated list is not currently supported. The default font face, if no <FONT> tag is in effect, or the FACE or FAMILY attribute is omitted from a FONT tag, is Arial. However, that default can be changed by calling the HtmlMessageBoxSetDefaultFontFace(name) function.
COLOR: The color for the text. Either a hard-coded color name, or a 6-digit RGB value, optionally preceded by "#". E.g. either FFFFFF or #FFFFFF for white. The default font color, if no <FONT> tag is in effect, or the COLOR attribute is omitted from a FONT tag, is black. There is no function to change this default.

 

The hard-coded font color names (again, case-insensitive) that the COLOR attribute currently recognizes are white, dkgray, ltgray, yellow, dkyellow, red, dkred, green, dkgreen, blue, dkblue, cyan, dkcyan, magenta, dkmagenta, cloudblue, orange and purple.

 

Entities:

 

The following HTML entities are recognized by the program, largely to ensure that if you actually want to display something like "<B>" in the MessageBox, you can do so:

 

&lt; - the less than sign, <
&gt; - the greater than sign, >
&amp; - the ampersand, &
&nbsp; - a non-breaking space, to prevent word wrapping from happening between words joined by this entity.

 

Having said this, the way the parser works you would probably almost never need either the &gt; or &amp; entities, and even the &lt; entity would only be needed if it was followed by a tag. E.g. "1 < 2" would come through fine, as would "<SomeWord>" or "Bob & Carol". It's only if you want to actually display text in your MessageBox like "<B>" or "the entity for ampersand is &amp;", say, that you would have to change them to "&lt;B&gt;" (or even "&lt;B>") or "the entity for ampersand is &amp;amp;" respectively.

 

Other HTML-like Behaviour

 

Spaces (or other whitespace) following a line break are ignored. All whitespace (carriage returns, newlines, and tabs) are treated as if they were spaces, unless HtmlMessageBoxSetNewlineIsBreak(1) has been called, in which case newline, or carriage return newline, is converted to "<BR>".

 

Multiple spaces are merged into single spaces, unless separated by tags. So, in "foo  bar", only one space will show. But in "<b>foo </b> bar", two spaces will show.

 

To really show spaces in either of the above situations, use &nbsp;.

 

What's Not Included

 

If it's not mentioned above, it's not included! That means things like hyperlinks, images (except the standard MessageBox icons displayed via codes in the flags argument to HtmlMessageBox), embedded objects like videos, etc., are not supported. In my humble opinion, none of those are needed for the purpose this product is intended for, which is to make your MessageBoxes more usable and readable.