Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: progress dialog

    In article <5fb7ca71.0309151532.36acc2e2@posting.google.com >,
    [email]wkung@hotmail.com[/email] (wes) wrote:
    > 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!
    1.) This is a powerplant question, so you should be asking in
    <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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139