HTML Applications Tutorial
#8It is at this juncture that I've decided to take a breather from all the coding and show you just what makes WEBlications so special. When an ordinary web page is launched, it opens up in Internet Explorer complete with with all the buttons and security features that are essential for surfing the Internet. What Microsoft have done is taken the core of Internet Explorer (the bit that handles scripting) and made it look like an ordinary program. Why? Because it enables scripts to be run that are not reliant on the presence of the Internet so the various security features can be switched off making scripts run much more seamlessly and to all intents and purposes are Windows programs that can be launched from shortcuts and menu's just like real programs. They even look like real programs complete with icons and menu's. But they can also make use of all of the features we associate with a web browser such as graphics and hyperlinks (hyperlinks are launched in IE proper so security is preserved).
To make WEBlications look even more like programs, the window containing the script can be controllled in certain specific ways. Here I am concerned with making them look more like ordinary Windows programs but there are other options that can be employed but these will not be gone into in any depth here. So, below is a WEBlication that does nothing but it does contain all the controlling code so we can test it all much more easily. The code is below. Don't be put off as I will explain it all further down.
<HTML>
<BODY>
<HEAD>
<title>Test</title>
<HTA:APPLICATION ID="Test"
APPLICATIONNAME="Test"
BORDER="thick"
CAPTION="yes"
ICON="test.ico"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="yes">
<Script Language=JScript>
window.resizeTo(200,150);
window.caption="Test";
</SCRIPT>
<Script Language=VBS>
</SCRIPT>
</HEAD>
<body scroll="no">
</BODY>
</HTML>
So what does it all mean? I'll go through it a line at a time.
<HTML>
<BODY>
<HEAD>
<title>Test</title>
This is the now familiar (I hope) beginning which is
just standard HTML.
<HTA:APPLICATION ID="Test"
The opening < (left sharp bracket)
is important and must not be ommitted. There is a closing >
(right sharp bracket) lower down. Here we specify that this is an
HTA which makes it different from a standard web page. We also
give this HTA a name and I have chosen to call it a (with little
or no imagination) Test.
APPLICATIONNAME="Test"
We also now can give this application a name. The Application
ID refers to the entire file and can be used to identify
elements within the page. The Application Name
is merely an identifier and the two need not be the same.
BORDER="thick"
This refers to the size of border which for a standard Windows
app is set to thick.
CAPTION="yes"
The caption is the title that appears at the top of the window and although it can be switched off, it means that users don't have access to all the usual Windows style controls they are used to.
ICON="test.ico"
You can even assign an icon which will be displayed in
the usual top left hand corner in the caption. This icon is a
standard Windows icon and must be placed in the same folder as
the .HTA file or a full path can be specified
although this makes the app less portable to other parts of the
users hard drive.
SHOWINTASKBAR="yes"
It is possible to prevent the WEBlication
from appearing in the task bar which may or may not be good thing
depending on the application but it is neverless a very useful
addition to the programmers armoury.
SINGLEINSTANCE="yes"
It is possible to prevent users from launching more than
one version of the script. This is useful if a database
application has been written and stops users overwriting with old
data because they inadvertently have two versions of the app
running.
SYSMENU="yes"
This enables the menu that is displayed when the icon in
the caption is clicked (just like any other Windows app) and is
the kind of control normally only available to Visual Basic
programmers. You get the option for free!
WINDOWSTATE="normal"
Can be minimized or maximized when launched (not to be
confused with the options below).
MAXIMIZEBUTTON="no"
This prevents the user from resizing the window by
greying out the middle button in the top right hand corner of the
window caption. Disabling this means that you don't have to add a
whole lot of code to reposition all of the controls (buttons,
text boxes etc..) when the window is maximised or set back to
normal.
MINIMIZEBUTTON="yes">
This allows the window to be minimized and can be
reactivated by the user clicking on the relevent part of the
taskbar. Note the closing > right sharp
bracket. That completes the window definitions. Now we can start
on the scripting sections as before.
<Script Language=JScript>
Now this is something that I hadn't intended to have to include. However, I have yet to find a VBScript version of this command so it has to be done in the alternative language that Microsoft provides for WEBlications called JScript (or Javascript as it is more commonly known). Scripts containing both languages can be mixed but cannot be nested one inside the other so we deal with this first.
window.resizeTo(200,150);
This will resize the window to a specific size.
</SCRIPT>
Now that is all we require of Javascript so we close it
down but we're not finished yet.
<Script Language=VBS>
Now we open up the VBScript section as usual. There is
nothing in it because we are testing the appearance of the window.
</SCRIPT>
</HEAD>
<body scroll="no">
And thats just about it. The one other option that is
sometimes useful is to switch off scrolling. This means that none
of the scroll bars that you normally get with web pages will
appear making it look more like a real app. However, it is
essential to ensure that the window is the right size for its
content when launched otherwise the user won't be able to scroll
around to see all of the content.
</BODY>
</HTML>
And thats it for this tutorial. Stand by for the next one any time now...