Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Slider&ProgressIndicator » ProcessMessages question
ProcessMessages question [message #3821] Wed, 28 June 2006 14:33 Go to next message
brianE is currently offline  brianE
Messages: 13
Registered: June 2006
Promising Member
I hope this is the right corner to be in...

Two related questions:
If ProgInd needs value and maxval to indicate progress then can I assume that there is a ProcessMessages or similar at work when inside a long loop? ie

for (int j=0;j<5000;j++)
{
// do something
ProgInd.Set(j,5000);
}

If I have a 'while' loop I cannot play that game (I don't know maxval) but I can show progress by writing to an EditInt:

int j = 0;
while (j<someval)
{
// do something
EdInt <<= j++;
}

But it never shows until the end! I need a ProcessMessages don't I? How do I accomplish this? Of course, I could be wrong and I hope you will set me on the right path.

BrianE
Re: ProcessMessages question [message #3822 is a reply to message #3821] Wed, 28 June 2006 14:37 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
There is ProcessEvents(). But don't know if that is useful in your case.
Re: ProcessMessages question [message #3827 is a reply to message #3821] Wed, 28 June 2006 19:30 Go to previous messageGo to next message
brianE is currently offline  brianE
Messages: 13
Registered: June 2006
Promising Member
Ah-ha, ProcessEvents! That's *exactly* what I needed! So now I can do what I want:

while(!in.IsEof()) {
    p <<= in.GetLine();
    num++;
    eNumLines <<= AsString(num);
    ProcessEvents();
}

or

while(num<100000) {
    p <<= in.GetLine();
    num++;
    PI.Set(num, 100000);
    ProcessEvents();
}


I'm sure you can see what I'm trying to do - but is there a better way?

BrianE
Re: ProcessMessages question [message #3828 is a reply to message #3821] Wed, 28 June 2006 20:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
There is "Step" and "StepCanceled". Usually, we do not even use "Set", just:

Progress pi("operationname");
pi.SetTotal(maxval);
for(int i = 0; i < maxval; i++) {
   if(pi.StepCanceled())
       return; // work is canceled;
   //... do work
}


Now if you do not know "maxval", simply omit the "SetTotal" part. Progress will show running strip instead.

You can also place "%d" to the description, it will be suplemented by number of times "Step" or "StepCanceled" was called:

Progress pi("Records processed %d");
....

Mirek
Re: ProcessMessages question [message #3829 is a reply to message #3828] Wed, 28 June 2006 20:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
P.S.: Step / StepCanceled calls ProcessEvents in implementation

P.P.S.: Use Step if you do not want "Cancel" button and canceling possibility.

Mirek
Re: ProcessMessages question [message #3831 is a reply to message #3821] Wed, 28 June 2006 22:55 Go to previous messageGo to next message
brianE is currently offline  brianE
Messages: 13
Registered: June 2006
Promising Member
Mirek,
That is so neat! With BCB I had to invent my own version but this is similar and just what I wanted. Perhaps I missed finding the words about it or maybe there aren't any - not being rude or ungrateful.

Supplementary questions: ProgressIndicator looks like a widget that can be incorporated into a layout. Can I do SetTotal(int) and Step() with it too? And ProgressInfo in the StatusBar? I will go and play and maybe find the answers before you tell me!

You guys are sooooooooo helpful.

BrianE
Re: ProcessMessages question [message #3832 is a reply to message #3831] Wed, 28 June 2006 23:04 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Yes, ProgressIndicator is normal widget. It however still lacks usc script description, in other words, you can add it using layout desinger as "user class" (it will show up as generic rectangle with classname).

Interface is different. For StatusBar there is another specific version.

Mirek
Previous Topic: Slider verticality bug or underdevelopment? [ADDED]
Next Topic: Use slider from layout designer?
Goto Forum:
  


Current Time: Thu Mar 28 22:47:54 CET 2024

Total time taken to generate the page: 0.01291 seconds