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?
 
Maybe something like document.body.style.cursor = "wait" and document.body.style.cursor = "default
 
taupirho,

Thank you for the response.

I have tried the lines you suggested, but they had no effect on the cursor.

I placed the document.body.style.cursor = "wait" line before the line of code that will take a while to complete and the line document.body.style.cursor = "default" after the code.

Any suggestion?

CluM09
 
Try adding an intermediate sub to make a small enough pause for the cursor to change...i.e.


Sub ChangeCursor
window.document.body.style.cursor = "wait"
Dim timeOut : timeOut= window.setTimeout("WorkingSection", 2000)
End Sub

Sub WorkingSection
...code that works
window.document.body.style.cursor = "default"
End Sub

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
dm4ever,

Yes, that does it. Thank you very much.

CluM09
 
dm4ever,

The hourglass cursor works only after I click on the button and move the mouse pointer away from the button.

The cursor does not change to hourglass when I left the mouse pointer on top of the button.

Any suggestion?

CluM09
 
Replace buttonID with your button's ID and try this:
Code:
window.document.body.buttonID.style.cursor = "wait"
 
Skie,

Thank you for the response.

I tried your suggestion, but I got an error "Object doesn't support this property or method: 'window.document.body.buttonID'"

Any suggestion?

CluM09
 
Skie,

The hourglass works if I click on the button and immediately move the mouse pointer away from the top the button. After about 2 to 3 seconds, I can move the mouse pointer back over button and the hourglass still shows.

It seems that in order to activate the hourglass, I have to move the mouse pointer away from the button immediately after I have clicked on the button.

I even extended the time for timeout from 2000 to 5000, and it still does not have any effect.

CluM09
 
Similar to what Skie was suggesting...replace "button1" with the ID of the button you click to execute your tasks.

Code:
Sub ChangeCursor
     window.document.body.style.cursor = "wait"
     window.document.getElementById("button1").style.cursor = "wait"
     Dim timeOut : timeOut= window.setTimeout("WorkingSection", 10000)
End Sub

Sub WorkingSection
	window.document.getElementById("button1").style.cursor = "default"
    window.document.body.style.cursor = "default"
End Sub

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
dm4ever,

Yes, that does it. I did not have the line below in the code since did not know the getElemenByID property of HTML.

window.document.getElementById("button1").style.cursor = "wait"

After I added the line, it works.

Thank you so much for the help.

CluM09
 
dm,
i can use this code on my app too. my question is, how do i invoke the "sub ChangeCursor"? i have a button that when i click it searches for a file/keywords. on the button, i have cursor="wait" on the html tag. when it's clicked, it executes "sub find_files". where would i put the "wait" and "default" things on the sub(s).
thanks.
 
The way you would do it is call a sub similar to the "changecursor" one I posted above instead of your "find_files" sub. That first sub would change the cursor and then wait for a little while using .setTimeout and it will then call the sub you tell it to.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
how would i assign two subs to one button? can i just put the code in "changecursor" into "find_file" sub? and do the timeout/wait, there?
thanks.
 
You're not calling two subs with one button. You button calls one sub and then that sub calls another. Look at the example posted...you should be able to see how the changecursor sub ends up calling the main sub with the window.setTimeout

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
dm4ever,

Do you happen to know what book I can buy to learn more about how to use the HTML properties and design the HTML page?

Any suggestion will greatly appreciated.

Thanks again.

CluM09
 
dm,
i got it. the button calls one sub, and that one sub calls another. cool.
thanks.
 
dm4ever,

Thank you for the information.

I have another poblem that I cannot figure out. I have a button on the html page called OK. I used the accessKey="o" to allow the Alt key to activate this button. How do I have underscore under the O character of the OK button?

CluM09
 
If the OK button has a unique ID then you can simulate a click with something like this.

window.document.getElementById("okbuttonid").click()

You may also want to check out this thread:


--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top