Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hourglass cursor in HTA form 1

Status
Not open for further replies.

cluM09

Technical User
May 15, 2004
127
0
0
US
Hello,

I have written an hta application that takes a while to complete the operation.

All the code to perform an operation is within the subroutine called RuntheScript. It is within this subroutine that I want to cursor to change to hourglass and then change back to default.

How can I show the users an hourglass cursor while they are waiting?
 
dm4ever,

Thank you for the response.

I do not want to simulate a click for the OK button. All I need is to underline the O character of the OK button so show the user that he can press the Alt + o to activate the button instead of using the mouse.

I can use the accessKey="o" allow the Alt + o combination to activate the button, but I want to show the underscore character underneath the O of the OK button.

Can it be done?

Thanks again.

CluM09
 
Oh...I see what you're saying...hmmm...I don't know if that possible.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
The only possible solution I could think of would've been to use the css ::first-letter psuedo-element.
Code:
<html>
<head>
<style type="text/css">
.inpButton { width:50px }
.inpButton::first-letter { text-decoration:underline; }
</style>
</head>
<body>
<input type="button" class="inpButton" value="Ok">
</body>
</html>
But, it looks like the psuedo-element does not work for buttons (probably all input tags).

So, you have two options. If you use the z-index, you could probably float an underlined "O" where your O is in your input tag. One thing with this solution is I don't know what happens if the click on the "O" text. The following is an example of what you'd use:
Code:
<span style="position:relative; right;20px; z-index:1; text-decoration:underline;">O</span>

Or you could create something that looks like a button, acts like a button, but isn't a button. Like a span tag with a border that makes it look like a button. Then you just fire whatever you want the button to do from an onClick event.

508 Compliance Warning
This isn't user-friendly to anyone who is visually impaired and requires a software that reads the page to them. A solution to this is to use an <a href=""> that in the onclick even it returns a false (preventing the page from going anywhere). Just make sure you clearly label what the non-link is going to do in the alt tag.
 
Skie,

Thank you for the response.

How would you add your span code to the follow line of code to generate the underline character for O letter?

<input id=okbutton type="button" value=" OK " name="OK_Button"
onmouseover="OK_Button.style.cursor='hand'" accessKey="o" onClick="RunScript">

Where can I insert the line "<span style="position:relative; right;20px; z-index:1; text-decoration:underline;">O</span>"?

CluM09
 
More free advice, perhaps worth its price:

1.) You need the setTimeout() call because an event handler does not allow window messages (like those created when you change the cursor style) to be processed until it completes. VB 5/6 programmers will recognize this as a place they might want to insert a DoEvents() call, but IE doesn't provide this function.

2.) You don't need to call setTimeout as a function unless you plan to use the returned result, i.e. cancel the timer.

3.) You don't need to use the DOM to reference objects in an HTA, IE supports the DHTML Object Model as well. I.e.:

[tt]window.document.getElementById("okButtonId").click()[/tt]

... is overkill. Just use:

[tt]okButtonId.click[/tt]

Or if the button is within a form [tt]frmMain[/tt]:

[tt]frmMain.okButtonId.click[/tt]

Note: No parens follow a subroutine call either! You'll get away with this in some contexts and then it'll bite you in another. Avoid doing this.

4.) You don't need to overqualify objects. The document object is in the global namespace:

[tt]window.document.body.style.cursor = "default"[/tt]

... is overkill, slower (though that's not too important here), and another place to make a typo. Use:

[tt]document.body.style.cursor = "default"
[/tt]

5.) Eschew <input type=button> elements. Use <button> elements instead. For a <button> element canHaveHTML = True.

6.) Avoid JavaScript event binding where practical. VBScript event binding is faster and clearer to read, and less error-prone. Instead of:

[tt]<input id=okbutton type="button" value=" OK " name="OK_Button"
onmouseover="OK_Button.style.cursor='hand'" accessKey="o"
onClick="RunScript">[/tt]

... use:

[tt]<input id=okbutton type="button" value=" OK " name="OK_Button"
onmouseover="OK_Button.style.cursor='hand'" accessKey="o">[/tt]

... and name the event handler okbutton_RunScript.

7.) Don't pad button caption values with blank spaces, Use the width style with a relative value instead.

8.) Consider disabling UI elements while your long-running process is active. This provides visual feedback and avoids possible reentrancy problems (user clicking the button a second time, etc.).

AccKey.hta
Code:
<HTML>
  <HEAD>
    <STYLE>
      .clsAccKey:first-letter {text-decoration: underline}
      BUTTON {width: 15ex}
    </STYLE>
    <SCRIPT language=VBScript>
      Option Explicit
      
      Sub btnClick_onclick()
        btnClick.disabled = True
        document.body.style.cursor = "wait"
        btnClick.style.cursor = "wait"
        'Long delay here just to simulate a long
        'running process visually for this demo.
        setTimeout "HiThere", 2000, "VBScript"
      End Sub
      
      Sub HiThere()
        document.body.style.cursor = "default"
        btnClick.style.cursor = "default"
        MsgBox "Hi There!"
        btnClick.disabled = False
      End Sub
    </SCRIPT>
  </HEAD>
  <BODY>
    <BUTTON id=btnClick accessKey=C class=clsAccKey>Click Me</BUTTON>
  </BODY>
</HTML>

The MSDN Library (linked above) is one of the best references. Even better if you have the CD version, preferably even a 2001 edition. Even though it will be outdated in places it contains information that seems to be dropped from earlier ones.

You might also try the installable Windows Platform SDK which has a subset "Internet Development SDK." This can also be ordered on CD for a nominal charge (in any of several versions).

I find that Visual InterDev 6.0 is still one of the best editors for writing HTAs. Though dated now (and never updated by Microsoft), it provides VBScript code colorization and Intellisense in Source View and lots of visual support in Design View as well as an easy test/debug facility in Quick View.

Some people say they've had luck using one of the .Net Express editions (VB.Net 2005? Visual Web Developer?) for editing and testing HTAs. I may have to give it a try.
 
dilettante,

Thank you so much for the help and the information for help on HTAs.

That is exactly what I am looking for. I will try to look for the help resources that you indicated.

From what I understand from your message, there is no other resources better than the MSDN Library, the "Internet Development SDK" from the Windows Platform SDK and the Visual InterDev 6.0.

I have been looking for books to learn HTML/HTAs, but I have not found anything that mentioned how to create the GUI preferences on the HTML page that I am looking for.

Thanks again

CluM09

 
The msdn library is very useful. Another good link is the w3.org html 4.01 elements. Sometimes you'll find something there that you couldn't find in the msdn library.

And, to go with what PHV posted:
This'll give you wall the properties of the HTA:Application tag. Last I checked, they don't provide a complete list at the HTA Developers Centr.
 
I wouldn't say none are better, but Microsoft's documentation tends to cover the quirks of IE, and all HTAs are based on IE technology. You'll also find the VBScript documentation there, and most of the generic sources on HTML fail to cover the DHTML Object Model in IE. Instead they focus on the DOM, since it is present and similar in most browsers.

Visual InterDev is just a development tool, more of a fancy editor. Great if you have it, useless if you don't because it is almost impossible to get now.

I hope to try out Visual Web Developer 2005 Express Edition for this purpose. It's free, which is always good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top