Monday 30 March 2009

Progress Bar in your status bar

Dale Jessop from 3M recently needed to create a progress bar that is embedded at the bottom of his form next to a status bar (as shown in the image). He has kindly offered to share this technique with readers of my blog.
Basically you need two editline controls on the window (STB_STATUS and PRB_TEST). one which will be an MS progress bar and one which will be an MS status bar. The examples I have taken the MS controls from are Sprezzatura examples and they are taken from:
  • STB_TEST
  • SEATTLE_2007_PRB_EX1
  • SEATTLE_2007_PRB_EX2
I have both of the controls on the window and both are turned into their MS equivalents on the CREATE event, after which I run the following code which embeds the progress bar within the status bar control.

Once the progress bar is embedded in the status bar you can use it the same as a normal status bar. I have also been able to mimic the behaviour of Internet Explorer by making the progress bar "appear, run and then disappear again".

0001 *//////////////////////////////*
0002 hidePrb:
0003 *//////////////////////////////*
0004 call set_Property( @window : ".PRB_TEST", "PARENT", @window)
0005 call set_Property( @window : ".PRB_TEST", "VISIBLE", 0)
0006 return
0007
0008 *//////////////////////////////*
0009 embedPrb:
0010 *//////////////////////////////*
0011
0012 stbSize = get_Property( @window : ".STB_STATUS", "SIZE" )
0013 prbSize = Get_Property( @window : ".PRB_TEST", "SIZE" )
0014
0015 * // Both sizes are relative to the parent form right now, so
0016 * // make the prbSize relative to the stbSize instead
0017
0018 PRBSIZE = STBSIZE
0019 prbSize<1> = prbSize<1> - stbSize<1>
0020
0021 if (prbSize<1> < 0) then prbSize<1> = 0
0022
0023 prbSize<2> = (prbSize<2> - stbSize<2>)+2 ; * Adjusted so the
0024 * progress bar looks like it is 'embedded' inside the
0025 * status bar
0026 prbSize<3> = 250 ; * Hard-coded the width of the control in
0027 * this instance
0028 prbSize<4> = (prbSize<4>)-3 ; * Adjusted so the progress bar
0029 * looks like it is 'embedded' inside the status bar
0030
0031 call set_Property( @window : ".PRB_TEST", "PARENT", @window :
0032 ".STB_STATUS" )
0033 call set_Property( @window : ".PRB_TEST", "SIZE", prbSize )
0034 call set_Property( @window : ".PRB_TEST", "VISIBLE", 1 )
0035
0036 return

9 comments:

  1. Get interested with this,
    Question...I just need to add editline control? What do I need to do in Create Event to turn the editline control to progress bar? How do I update the progress bar? Thanks first

    ReplyDelete
  2. Thank you for your comment. I will email you direct as I’m not a programmer and for this reason I am unable to comment much more than what is provided by Dale in the posting.

    I suspect that the code Dale provided is run on the Windows’ CREATE event, but I am only guessing. I would suggest initially looking at the following SENL from Sprezzatura (http://www.sprezzatura.com/senl/senl440307.pdf) as this has a article on the progress bar. I think that this along with the code from Dale should help you.

    ReplyDelete
  3. To do what Dale's doing you'll need a copy of the RDK referenced in the article above by Martyn. Just ask Martyn and he'll mail it - it's Sprezz freeware but should be used in conjunction with a reading of the article!

    ReplyDelete
  4. Thanks Sprezzatura. The file has just been emailed over to Lee.

    ReplyDelete
  5. Dear All,
    Billion thanks for helping me in this!
    It does solved my problem!
    Thanks!

    ReplyDelete
  6. You are welcome - I'm just glad that some of you are finding this blog useful ;)

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. Sorry Barry - Your posting was not censored and I thought it would simply be removed as Carl sent the files without a notice such as that above - I'm learning fast ;)

    I will publish both posts shortly.

    ReplyDelete
  9. Grrrr - Can't republish comments that have been declined using the moderator. Barry's postings were:

    "Could I have the Sprez RDK code as well please.
    TIA"

    "Ignore my request for code. Carl sent it to me.
    I had emailed sprez before I saw the note to get it from you."

    Sorry for any confusion.

    ReplyDelete