Introduction

Windows now features a full line of Development Systems and Studios to
make life easier for the Windows Programmer. These studios rely on and
take advantage of the same Dynamic Link Libraries(DLL's) and Microsoft
Foundation Classes(MFC's) that Windows uses. This adds efficiency and
saves on hard-disk space. Visual C++ is one such Windows Development
System. Ironically, newer versions of Windows are coded using Visual
C++. How interesting this is, Windows uses itself to re-create
itself. It's almost like a new breed of organisms! Actually, this is a
sign of a very good, complete operating system. Many systems
(i.e. programming langauges) are able to use themselves to generate
newer versions.

Internet Explorer has evolved a significant amount since its version
3.0 was introduced a few years back. Dynamic HTML is equipped with its
own hierarchy, programming languages, you name it. You can almost run
your computer with it. Now what if we took the DHTML in IE and used it
to re-create IE. Is this possible? Of course it is, using the new HTML
Applications (HTA's) that Internet Explorer 5.0 now supports.

The HTML Application Defined

The HTML Application (HTA) is just like any ordinary HTML document
that you would use in a web page, it can use the exact same
code. The only difference is that an HTML Application runs just like
an executable (.exe) file and does not need the browser open to run!
Crazy isn't it? You can now create Windows Applications using HTML and
scripting code!

Why Use HTML Applications?

HTA's can do anything a web page can do plus it has added
functionality. The user can re-configure how the window looks and
HTA's are viewed by the operating system just as any regular
executable file (.exe). With this, HTA's are trusted formats that are
not subject to security issues that you will find in web pages. You
have the option of ditching the complicated antics of Visual C++ and
instead use DHTML to code an executable file.

HTA Limitations

HTA's will only read what is specified within the Explorer's native
DOM. In other words, you cannot use the external property to
access foreign heirarchies like you can with an HTML document viewed
in Explorer.

How Do I Make An HTML Application

All that you have to do to make an HTML Application is simply change
the extension on an HTML file to that of .HTA. You may add
some special syntax in the <HEAD>, which we will
discuss, but HTA's are very forgiving and all you really need is
text. For example, look at the code for the following two HTA files,
they are both valid HTA's:

<html>
<body>
This is an HTML Application, just text, that's it!
</body>
</html>

The New <HTA:Application> Element

In good practice, you should use the <HTA:Application> element
in the <HEAD> of each HTML Application. This new element
contains attributes that will allow you to customize the appearance of
the HTA window. These attributes may be written using inline HTML and
read (and sometimes written as well) with scripting. Though we
will cover the attributes of this new element in detail, a general
HTML schematic with all attributes and possible values attained from
Microsoft's site looks like this:

ID

Allows you to name the <HTA:Application> element so that you may
read or write its attributes via JScript.

applicationName

Names the HTML Application. The value entered here is NOT the one that
will display in the title bar. When numerous HTA's are open at the
same time the operating system refers to each instance based on this
attribute. Read-only Scripting Syntax:[sApplicationName] =
appId.applicationName

borderStyle

static -3-D border typically used for windows that do not accept user input.

sunken -sunken 3-D border

Read-Only Scripting Syntax:[sBorderStyle] = appId.borderStyle

caption

Defines whether or not the application will have a title bar. If there
is no caption the minimize/maximize buttons, title, and icon will not
appear. Possible string values using inline HTML are:

yes -title bar is diplayed (default)

no -title bar is not displayed

Read-Only Scripting Syntax:[sCaption] = appId.caption

icon

Specifies a path to a .ico file (32 x 32 pixel bitmap file) to be used
as an icon to appear in the upper left-hand corner of the
application. If no path is specified, or the path is not valid, then a
default system icon of some sort will be displayed. To make a Windows
icon file (.ico) you may either download an editor of some sort like
IfranView32 or simply create a bitmap file (.bmp) that is 32x32 pixels
and then change the .bmp extension to .ico.

Read-Only Scripting Syntax:[sPath] = appId.icon

maximizeButton

Defines whether or not a maximize button will be diplayed in the
caption (title bar). Possible string values using inline HTML are:

yes -maximize button is diplayed (default)

no -maximize button is not diplayed

Read-Only Scripting Syntax:[sMaximizePresent] = appId.maximizeButton

minimizeButton

Defines whether or not a maximize button will be displayed in the
caption (title bar). Possible string values using inline HTML are:

yes -minimize button is diplayed (default)

no -minimize button is not diplayed

Read-Only Scripting Syntax:[sMinimizePresent] = appId.minimizeButton

showInTaskBar

Defines whether or not the HTML Application will appear in the Windows
taskbar alongside the START button. No matter what, the HTML
Application will still be visible after pressing ALT+TAB. Possible
string values using inline HTML are:

commandLine Method

Retrieves the string used to launch the HTML Application. An empty
string will be returned if the HTA is launched via an HTTP protocol.

Read-Only Scripting Syntax:[sPath] = appId.commandLine

Applications Within Frames

HTML Applications may also be defined within the FRAME and IFRAME
elements of an HTML document viewed within Explorer. Within the
framesets simply add the APPLICATION attribute and assign it
a string value of either yes or no (default). For
example, <IFRAME APPLICATION="yes" SRC="myPage.html">.

If set to yes the frame will be treated as an HTA within the
browser and will not be subject to security restrictions, and vice
versa. If you want nested frames to be treated as applications as
well, each nested frame and parent frame must contain an
APPLICATION attribute set to yes.

As a security precaution, FRAMES and IFRAMES that are
not-trusted (APPLICATION="no") are forbidden from interacting
with the trusted frames through scripting.

Making a Web Browser Using DHTML

Making a web browser using C++ has taken thousands of experts years to
try and perfect. However, in the next example, we will make a
fully-functional web browser in minutes using DHTML and JScript.

Conclusion

With the introduction of Internet Explorer 5.0, it is now possible to
use HTML code and scripting languages to create an independent Windows
application that does not need the browser to run. The HTA format is a
trusted format that is not subject to security restrictions that web
pages have. The same elements used in web pages via HTML can now be
implemented and converted into full-fledged Windows application.

Resources

A plethora of information on HTA's can be obtained from Microsoft's
site. All specifications in this article were taken directly from the
following site: