Page 1
Page 2
The Prelude
It seems that all too often designing
an effective user interface for the Pocket PC turns out
to be a daunting task. As a developer, I usually find myself
between a rock, aesthetically pleasing the end user, and
a hard place, making best use of the limited screen size.
Finally, through necessity, a control was born. Dubbed the
HTMLViewer, this control is essentially an ActiveX
wrapper for basic HTML functionality. The HTMLViewer has
allowed me to display information to the user in a much
easier and creative way, rather than trying to cluster controls
together and swapping frames. In other words, this control
has given me more control. Before we get too much further
I should point out that the HTMLViewer control outlined
in this article will be distributed as Open Source.
The Capabilities and Demo App
The HTMLViewer control provides much
of the necessary capabilities found in the HTML 3.2 standard.
I dont say that it supports everything related to
HTML 3.2 because I cant honestly say that Ive
tested every tag. However, all the major tags are present
- pictures (gif, jpg, and bmp have been specifically tested),
tables, frames, links, bookmarks, and various formatting
tags. Really the only way to find out if your favorite tags
are supported is to download the control and try it out.
There are two parts to the HTMLViewer:
- A basic desktop version to
allow you to draw the control onto your form at design
time.
- A Pocket PC version that contains
the actual code needed to facilitate HTML capabilities
on your device at run time.
Note: The reason for two separate controls
stems from the differences in the operating systems and
processor architectures (x86, ARM, SH3, etc.) of the desktop
and Pocket PC. However, this is not as inconvenient as it
sounds. Usually you can just copy over certain files from
your eVC++ project to your desktop C++ project and make
a few minor changes, sometimes changes arent even
required. The first reference link at the end of this article
has more on this topic.
If you choose to download the control
please follow the instructions in the ReadMe file
before attempting to install and use it. The download is
a WinZip self-extracting file that will expand into multiple
folders containing the compiled code, source code, and test
pages. You must at least register the desktop version with
the operating system before you can properly open the demo
application in eVB. Control registration is covered in the
ReadMe file. Once the desktop control has been successfully
registered and included as a component in the application,
the icon that appears in your toolbox should look like this:

You can place the control on the form
in the usual way and resize or move it as desired. Below
is a screen shot of the demo application included with this
control.

The control contains two methods - LoadHTMLString,
which takes a string parameter containing HTML text, and
LoadHTMLFile, which takes a string parameter representing
a fully qualified filename (path + filename), a bookmark,
or a combination of the two (path + filename + bookmark).
You would typically use the LoadHTMLString
method as follows:
Dim HTMLText As String
HTMLText = "<HTML>"
HTMLText = HTMLText & "<HEAD></HEAD>"
HTMLText = HTMLText & "<BODY>"
HTMLText = HTMLText & "<IMG SRC='\Snowman.gif'>"
HTMLText = HTMLText & "<H3>Merry Christmas</H3>"
HTMLText = HTMLText & "</BODY>"
HTMLText = HTMLText & "</HTML>"
Call HTMLViewer1.LoadHTMLString(HTMLText)
To use the LoadHTMLFile method you could
do one of the following:
Call HTMLViewer1.LoadHTMLFile("\My
Documents\MyFile.html")
Call HTMLViewer1.LoadHTMLFile("#MyBookmark")
Call HTMLViewer1.LoadHTMLFile("\My Documents\MyFile.html#MyBookmark")
In the demo application, the single-line
textbox at the top is used to enter information sent to
the ActiveX control through LoadHTMLFile, and the
multi-line textbox is used to send text through LoadHTMLString.
By typing the path and filename of a file into the single-line
textbox and then tapping the "Load" button beside
it, you can view both the contents of the file in text and
HTML format.
Next Page