Ask a Question related to Mac Programming, Design and Development.
-
wes #1
progress dialog
I'd like to create a progress dialog box while saving a large file
from my application. I have tried to create a modal DB and calling
DoDialog() inside the for loop of my saving routine, however, I can
only see a "blank" dialox, there is no content in it, my code is as
follows:
StDialogHandler theHandler(RESID, ...);
for (i=0; i<totalLineNum; i++)
{
// save data one line at a time
saveData(buf, ...);
theHandler.DoDialog();
}
I wonder if it is necessary for me to create a more complicated
progress dialog (for example, using another thread to launch the
dialog)? And if there is any sample code I can use? Thanks!
wes Guest
-
progress bar
Hello, I'm trying to implement progress bar for calculations. I opened dialog (none-modal) with ProgressBar and set Max value for ProgressBar... -
ADM progress bar
Hello! I have tried to create an ADM progress bar (kADMProgressBarType) in my plugin. However, it doesn't seem to be a way to update it. Anyone... -
progress
I am getting a "little" frustrated with a guy here that keeps insisting Informix is crap, and Progress is the best database in the world. Anyone... -
Progress Bar help, please
Greetings.. i'm a Flash newbie using Flash MX. I need to do a "progress bar" and I don't know where to start. I have a swf file ready to go on the... -
progress bar GO AWAY!
I'm using the 2004pro component progress bar and i'm using it with the scrollpane inside my movie. it works just fine except for the fact that after... -
David Phillip Oster #2
Re: progress dialog
In article <5fb7ca71.0309151532.36acc2e2@posting.google.com >,
[email]wkung@hotmail.com[/email] (wes) wrote:
1.) This is a powerplant question, so you should be asking in> I'd like to create a progress dialog box while saving a large file
> from my application. I have tried to create a modal DB and calling
> DoDialog() inside the for loop of my saving routine, however, I can
> only see a "blank" dialox, there is no content in it, my code is as
> follows:
>
> StDialogHandler theHandler(RESID, ...);
>
> for (i=0; i<totalLineNum; i++)
> {
> // save data one line at a time
> saveData(buf, ...);
>
> theHandler.DoDialog();
>
> }
>
> I wonder if it is necessary for me to create a more complicated
> progress dialog (for example, using another thread to launch the
> dialog)? And if there is any sample code I can use? Thanks!
<news:comp.sys.mac.oop.powerplant>
2.) You don't need threads, but you will need to
2.a) tell the LProgressBar how manu lines you've got (and
you may need to put up an indeterminate progress bar before that.)
2.b) every few lines, tell the LProgressBar how much progress you've
made.
3.) Either look at the return value of theHandler.DoDialog(), or
throw or make something a listener to listen for the "Stop" button
on the progress dialog. (Use "Cancel" if your application can
revert the state to undo the long operation. Use "Stop" if you can't
undo the partial long operation.)
4.) When debugging progress dialogs, it is useful to add a temporary
"test" menu command that just LWindow::CreateWindow() the window
to make certain that it would draw correctly if it were a normal,
modeless window. (I think you've got some problems here, since
theHandler.DoDialog() would draw it if it were correct.)
5.) It is nice to let the user know how long its going to take.
Here is my code for that:
void StProgress::UpdateTimeEstimate(float n, SInt16 units){
Str255 s, s1, s2;
if(20 < n){
SInt32 m = (n + 2.5) / 5;
n = m*5;
}
NumToString(n + 0.5, s1);
if(EqualString(s1, "\p1", true, true)){
ParamString(s, kProgressTime1Strings, units, s1);
}else{
ParamString(s, kProgressTime2Strings, units, s1);
}
ParamString(s2, kProgressStrings, kTimeEstimateS, s);
if(not EqualString(s2, mSaveTimeEstimate, true, true)){
LString::CopyPStr(s2, mSaveTimeEstimate);
mTimeEstimate->SetDescriptor(s2);
}
}
void StProgress::UpdateTimeEstimate(){
if(0 == mMax or 0 == mValue){
return;
}
SInt32 elapsedTime = TickCount() - mInitialTime;
SInt32 totalTime = elapsedTime*mMax/static_cast<float>(mValue);
SInt32 remaining = totalTime - elapsedTime;
// don't estimate too early on a long progress.
if(elapsedTime < 10*60 and 60*60 < totalTime){
return;
}
if((60*60*60*24*364.25) <= remaining){
UpdateTimeEstimate(remaining / ( 60*60*60*24*364.25), kYearS);
}else if((60*60*60*24*30.) <= remaining){
UpdateTimeEstimate(remaining / ( 60*60*60*24*30.), kMonthS);
}else if((60*60*60*24*7) <= remaining){
UpdateTimeEstimate(remaining / ( 60*60*60*24*7.), kWeekS);
}else if((60*60*60*24) <= remaining){
UpdateTimeEstimate(remaining / ( 60*60*60*24.), kDayS);
}else if((60*60*60) <= remaining){
UpdateTimeEstimate(remaining / ( 60*60*60.), kHourS);
}else if((60*60) <= remaining){
UpdateTimeEstimate(remaining / ( 60*60.), kMinuteS);
}else if((60) <= remaining){
UpdateTimeEstimate(remaining / ( 60.), kSecondS);
}
}
David Phillip Oster Guest



Reply With Quote

