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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA refresh progress

Status
Not open for further replies.

Geates

Programmer
Aug 25, 2009
1,566
US
I know this issue has been talked about a lot. I have a beauty of a progress meter, just having difficulty implementing it with a speedy refresh! I've use timed delays

Code:
sub delay (intMilliSecs)
    dblStart = cdbl(timer)
    do while ((cdbl(timer) - dblStart) < (intMilliSecs / 1000)) : loop
end sub

This showed that the updating ISN't depended on time passed but rather focus?

Code:
sub updateDisplay
   set objShell = WScript.CreateObject("WScript.Shell")
   objShell.Run "%COMSPEC% /c", 0, false
end sub

This works because focus is moved from the HTA to the COMSPEC and then back to the HTA. I would assume the focus forces an update to the HTA display. The problem is that this routine is SLOW.

So I tried retriggering focus
Code:
sub updateDisplay
   set objApp = WScript.CreateObject("Wscript.Application")
   objApp.AppActivate "appName"
end sub

But this doesn't work at all.

Removing the progress meter would speed up the routine that uses it by tens of times - but I want that graphical representation. Does anyone have further suggestions or explaination of why this is mostly futile?

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Have you searched this forum for progressbar ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I have, and found nothing. They relate to incorporating ActiveX controls or showing progress during file copies (a code snippet you seem to be quite familiar with:).

My question is more regarding why do my methods not work? What is it about an HTA that prevents display updating during script excution.

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
using the setInterval method seems to be my best best. Although, I wanted to see if anyone had another suggestion.

Thankx for the link. It more concisely explains how to use setInterval for this exact purpose better than any other doc I've read.

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
What a NIGHTMARE!! I couldn't wrap my head around how to implement setTimeout into me code. Last last night, I had an ephiphany and was able to write up a demo in no time.

Thinking it would only take a few minutes for me to implement it in my code was a little naive. It took my about 4 hours only to realize that it's SLOWER (in my case) than my first updateDisplay routine... Damn!

Anyway, here's demo I wrote
Code:
<head>
	<title>Progress</title>
	<HTA:APPLICATION 
		APPLICATIONNAME="Progress"
		SCROLL="NO"
		SINGLEINSTANCE="yes"
		CAPTION="yes"
	>

	<style>

	#meter {
		filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#7E7562', EndColorStr='#BBB4A5');
		height:25px;
	}
	
	#meter_container {
		width: 200px;
		height: 27px;
		border: 1px solid #000000;
	}
	
	</style>

</head>


<script language="VBScript">
	dim intRows
	dim intCells
	dim intIterate
	
	sub doProgress
		if (intIterate <= (intRows * intCells)) then
			'DO STUFF
			intWidth = formatNumber(((intIterate / intCells) / intRows) * 100, 2)
			text.innerHTML = intIterate & " / " & (intRows * intCells) & "  (" & intWidth & "%)<br>"
			meter.style.width = intWidth & "%"
			'STUFF DONE
			
			intIterate = intIterate + 1
			setTimeout "doProgress", 50
		else
			text.innerHTML = "DONE"
		end if
	end sub
	
	sub initProgress
		text.innerHTML = ""
		set objTable = document.getElementById("data")
		intRows = objTable.rows.length
		intCells = objTable.rows(0).cells.length
		intIterate = 0
		doProgress
	end sub
	
	window.resizeTo 240, 120
</script>	
	
<body>
	<span id="text"><a href="#" onclick="initProgress()">begin</a></span>
	<div id="meter_container">
		<span id="meter"></span>
	</div>
	
	<div style="display: none">
		<table id="data">
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>
			<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>

		</table>
	</div>
</body>

Again, it was coded with my needs in mind - to read a massive table of data.

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top