Top  Previous  Next

The HTML MessageBox is an almost exact replacement for the standard Windows API MessageBox function, but with added functionality. The following are some of the features of the HTML MessageBox that it has in common with the Windows MessageBox:


It auto-sizes to exactly fit the text (or HTML) being displayed.
Long lines are word wrapped.
It is centered on your screen.
You can specify which buttons are to be shown, which icon (if any) is to be shown, and which is the default button, via codes passed to the function in its flags argument.
The function returns a code indicating which button was selected.
Unless one of the buttons is "Cancel", there is no Close button at the top right of the MessageBox (or it is inactive).
If there is a "Cancel" button, pressing ESC or clicking the close button at the top right activates it.


The following are some of the improvements of the HTML MessageBox over the standard Windows MessageBox:


It will never be wider than your screen, or taller than your screen. (In fact, it tries to avoid being more than about 90% of the width or height of your screen.) The only exception to this is if there is a too-long unbreakable line in the message, e.g. one with no spaces in it at all.
The "text" argument can contain simple HTML, to provide emphasis and thus make it more readable/usable.
The font defaults to Arial 10 (which is in general significantly larger, and thus more readable, than in the Windows MessageBox), though that can be changed either individually with the <FONT> tag, or by changing the defaults.


There is one significant difference of the HTML MessageBox in comparison to the Windows API MessageBox. In the Windows MessageBox, newline characters (ASCII 10) force a line break. In the HTML MessageBox, by default they do not (they are just treated as whitespace, as in HTML) and <BR> is used for line breaks. However, you can change this behaviour by calling the function HtmlMessageBoxSetNewlineIsBreak(1). After that has been called, newlines (or carriage returns followed by newlines) are again treated as line breaks. Calling this function allows you to use the HtmlMessageBox as an almost completely seamless replacement for all Windows MessageBox function calls in your application.


Some of the less important flags that can be passed to the Windows MessageBox function are not implemented by the HTML MessageBox at this time. Details are in the reference.


See Also: HTML Recognized by the MessageBox