Professional Web Applications Themes

progress dialog - Mac Programming

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 ...

  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. #2

    Default Re: progress dialog

    In article <5fb7ca71.0309151532.36acc2e2posting.google.com >,
    [email]wkunghotmail.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

Similar Threads

  1. progress bar
    By Sergey Bogdanov in forum Macromedia ColdFusion
    Replies: 14
    Last Post: April 16th, 03:17 PM
  2. ADM progress bar
    By Lars_Romedahl@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 1
    Last Post: October 6th, 09:06 AM
  3. progress
    By Dirk Moolman in forum Dreamweaver AppDev
    Replies: 35
    Last Post: April 27th, 10:19 AM
  4. Progress Bar help, please
    By Diode in forum Macromedia Flash Sitedesign
    Replies: 5
    Last Post: February 18th, 05:21 AM
  5. progress bar GO AWAY!
    By Markooshio webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 6
    Last Post: January 31st, 04:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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