Progress Bar

Author Message
TNO

  • Total Posts : 2094
  • Scores: 36
  • Reward points : 0
  • Joined: 12/18/2004
  • Location: Earth
  • Status: offline
Progress Bar Sunday, December 31, 2006 10:16 PM (permalink)
0
Next up on the platter, A slick progress bar:

Save this as progress.html:
 <html>
 <head>
 <title>Please Wait</title>
 <script type="text/javascript">
 var part=0;
 var whole=100;
 function progress(part,whole){
    if(part>=whole){
        self.close();
    }
    else{
        document.getElementById("status").innerText=Math.round(part/whole*100) + "%";
        document.getElementById("LB1").style.width=Math.round(part/whole*100);
    }
 }
 window.returnValue = self;
 </script>
 </head>
 <body style="background-color:black;color:white">
 
 <span id="LB0" style="position:absolute;left:50%;top:50%;">
   <span style="position:absolute;font-family:arial;font-size:10px;color:#FFFFFF;left:-50;top:-18">
       <span id="message">Checking...</span><span id="status"></span>
   </span>
   <span style="position:absolute;left:-50;top:-5;font-size:1px;width:100;height:10px;background:#333">
       <span id="LB1" style="position:absolute;left:0;top:0;font-size:1px;width:0;height:10px;background:#FFFFFF"></span>
   </span>
 </span>
 </body>
 </html>
 


In your HTA or HTML do this to start the progress bar:
 var progress=window.showModelessDialog("progress.html",self,"dialogHeight: 200px; dialogWidth: 400px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
 

This will assign the progress bar to a variable and keep the window on top at all times. when the progress bar reaches 100% it will close itself

How to update the progress bar:

First you should determine the total length of the items you are going through, wether it be the length of an array, or total number of objects.
Inside your loop update the progress bar like this:

progress.progress(current index,Total Elements - 1); //0 based array

To update the message in the progress bar:

progress.getElementById("message").innerText="Checking hidden files"

Example to play with:

test.hta
 <html>
 <head>
 <title>Progress bar test</title>
 </head>
 <body>
 <button onclick="doIt()">GO!</button>
 <script type="text/javascript">
 function doIt(){
    var progress=window.showModelessDialog("progress.html",self,"dialogHeight: 200px; dialogWidth: 400px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
    for(var i=0;i<4000;i++){
        progress.progress(i,4000)
    }
 }
 </script>
 </body>
 </html>
 
<message edited by TNO on Friday, May 22, 2009 4:05 AM>
To iterate is human, to recurse divine. -- L. Peter Deutsch
 
#1
    dm_4ever

    • Total Posts : 3687
    • Scores: 82
    • Reward points : 0
    • Joined: 6/29/2006
    • Location: Orange County, California
    • Status: offline
    Progress Bar Monday, January 08, 2007 6:15 AM (permalink)
    0
    This is definitely a slick progress bar.   It doesn't seem to close automatically for me though. No errors or anything. Any ideas?
    <message edited by TNO on Friday, May 22, 2009 4:05 AM>
    dm_4ever

    My philosophy: K.I.S.S - Keep It Simple Stupid
    Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
    Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      TNO

      • Total Posts : 2094
      • Scores: 36
      • Reward points : 0
      • Joined: 12/18/2004
      • Location: Earth
      • Status: offline
      RE: Progress Bar Monday, January 08, 2007 10:00 AM (permalink)
      0
      I didn't set the sample up to close itself for display purposes. The fix is simple though:

        for(var i=0;i<4001;i++){
            progress.progress(i,4000)
        }

      Its standard practice in loops to have 1 extra in the total loop count since arrays/indexes are 0 based vs the length value of most objects.
      <message edited by TNO on Friday, May 22, 2009 4:05 AM>
      To iterate is human, to recurse divine. -- L. Peter Deutsch
       
      #3
        vishalkbhatt

        • Total Posts : 6
        • Scores: 0
        • Reward points : 0
        • Joined: 12/13/2010
        • Status: offline
        Re: RE: Progress Bar Wednesday, January 19, 2011 10:35 PM (permalink)
        0
        Hi TNO thanks for replying..
        I went thru all three links u sent...and this one looks very good, But I dont know if this progress bar can be included in my vb script so that it can fulfill my requirement, which is when my script is running the user should see that the script is running and notified when the run is completed. So if it is possible with this progress bar then pls show me how to do it with my vbs..
        thanks,
        Vishal
         
        #4
          TNO

          • Total Posts : 2094
          • Scores: 36
          • Reward points : 0
          • Joined: 12/18/2004
          • Location: Earth
          • Status: offline
          Re: RE: Progress Bar Monday, January 24, 2011 5:11 PM (permalink)
          0
          Without knowing anything at all about how your code is set up. I'll just say use MsgBox "Done" after the progress bar completes
          To iterate is human, to recurse divine. -- L. Peter Deutsch
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 2 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9