#1
  1. Huh?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Scotland, UK
    Posts
    223
    Rep Power
    11

    how to use progress bars in c++


    I am looking into using a progress bar in my program but the BCB Manual has got no useful info in it regarding this.

    What i am trying to do is when a form is opened it creates a tree view depending on items in a database. The test data i am using is quite small (<100 records) and when the form is opened the treeview can clearly be seen building itself. This is not a problem just now but when the program is fully developed and in use there is going to be a lot more records and the tree will take much longer to be built. What i want to do is have a progress bar appear until the tree has finished building itself and then the form will be shown... fully constructed.

    However, i cannot find any useful info on this. Can it be done? Is it difficult?

    If any more info is needed please ask!

    Thanx 4 the help

    :-)
    -----------------------------------------------------------
    4dr14n
  2. #2
  3. Bad Andy
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    OH
    Posts
    275
    Rep Power
    11
    Well, here is the basic setup:

    ProgressBar1->Position = 0;//clear
    ProgressBar1->Step = ProgressBar1->Max/10;//set increment
    while (ProgressBar1->Position != ProgressBar1->Max){
    if (condition)
    ProgressBar1->StepIt();//adds one increment
    var++;
    }

    In your case, the only way I could think to do it is to increment a variable throughout the process of loading the tree, and then increment the progressbar accordingly. Howerever, there may be an easier way to do this, I just started messing w/ the progress bar. For more info seach TProgressBar in the Help.
  4. #3
  5. Huh?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Scotland, UK
    Posts
    223
    Rep Power
    11
    Thanx...

    i am away to play about with it just now!

    ur input is appreciated...making my project a bit easier anyway!:)
    -----------------------------------------------------------
    4dr14n
  6. #4
  7. Huh?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Scotland, UK
    Posts
    223
    Rep Power
    11
    another question :D ....

    how do you put a progress bar into a status panel. I can only get text to appear in the panel.

    Any ideas?
    -----------------------------------------------------------
    4dr14n
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    Try creating it programmatically:
    Code:
    // In the class declaration
    TProgressBar *prgBar;
    ...
    ...
    // In the FormCreate event
    prgBar = new TProgressBar(StatusBar1);
    prgBar->Parent = StatusBar1;
    prgBar->Top = 2;
    prgBar->Min = 0;
    prgBar->Max = 100;
    prgBar->Position = 0;
    ...
    ...
    // In some update event
    prgBar->Position = somevalue;
    HTH :)

IMN logo majestic logo threadwatch logo seochat tools logo