Hello All,

I would like incorporate a progress bar in our app, so i searced the
archives for some references and found the code below. I followed the advice
and the SDK.  I include the Progress.h but not all the functions seem to be
included. The PrgStartDialog function is not reconized by my compiler (CW6).
Is there anything else besides the include that I should be doing???

TIA,

Alex

----- Original Message -----
From: Mitch_Fawcett <[EMAIL PROTECTED]>
To: Palm Developer Forum <[EMAIL PROTECTED]>
Sent: Friday, March 10, 2000 7:01 PM
Subject: RE: twiddle thumbs in long computations?


Progress manager is tricky, but the following should help.

Create a starter program with a simple form with
a button.  Have the button execute the code in step #3 below when it is
tapped.  This example is highly simplified to show you how the Progress
manager works in a very basic way.  Once you understand the sample, the SDK
should
make more sense. This code was cut & pasted with minor modifications from
a bigger program I wrote .

The code I'm providing was written with Gnu C Compiler in mind.

Good luck!

Mitch
Tapn'see Software


1) Include a reference to Progress.h in your program. You'll need to refer
to structures named PrgCallbackData and ProgressPtr that are defined in
Progress.h.

2) You'll need a callback function.  The following callback will let your
program display a series of six progress messages while your progress is
running.  You are not stuck with these messages.  You can play around with
the code and have any messages you want displayed.  The "stage" value is
sent to this function via the PrgCallbackData structure which you populate
in the PrgUpdateDialog function. It gives you a way to decide what message
you want to display.


/* Callback function start
*********************************************************/
static Boolean MyCallback (PrgCallbackData *callbackData)
{
#ifdef __GNUC__    // I need this because I am using GCC.
  CALLBACK_PROLOGUE
#endif

  if (callbackData->stage == 1)
    StrCopy (callbackData->textP, "Stage 1");
  if (callbackData->stage == 2)
    StrCopy (callbackData->textP, "Stage 2");
  if (callbackData->stage == 3)
    StrCopy (callbackData->textP, "Stage 3");
  if (callbackData->stage == 4)
    StrCopy (callbackData->textP, "Stage 4");
  if (callbackData->stage == 5)
    StrCopy (callbackData->textP, "Stage 5");
  if (callbackData->stage == 6)
    StrCopy (callbackData->textP, "Done!");

 #ifdef __GNUC__
  CALLBACK_EPILOGUE
#endif

    return (true);  // See the SDK. Need to return "true" in most cases.
}
/* End of callback function
****************************************************/

3) Have the following code execute when you tap the form button. As the
progess dialog is updated it will display a series of messages and end with
"Done!".  I think in most instances you will want to make the dialog
disappear automatically as soon as your process ends, but in this case I
leave it up.  Tap the cancel button to get rid of it.

/* start of function
****************************************************************/

  EventType       event;
  ProgressPtr pPrg;
  Word wStage = 0;
  Boolean       booDone = false;

  // Start the progress dialog. Identifies the callback function.
  pPrg = PrgStartDialog ("Work in progress....", * MyCallback);

    // Here is the "event loop" that the SDK refers to.
    // Within the loop you check for events.  If no event is in the queue,
    // you drop into a sub-loop and do some work.  If there is an event,
    // you pass it to the PrgHandleEvent function. In this example, a
    // likely event that will be passed to it will be a tap on the "cancel"
    // button on the progress dialog. If there's a system event,
    // PrgHandleEvent will hand it off to the system event manager.

  while (!booDone)
    {
      EvtGetEvent (&event, 50);  // checks for an event every 1/2 second.
      if ((event.eType == nilEvent) && (wStage < 6))
{
         // This is where your long running process would do some work.
         // In this case, I'm not doing anything other than updating the
         // progress dialog. You might have to do some clever thinking to
         // reorganize the flow of your process so it can be broken up into
chunks.

         wStage++;  // Creating a value for stage that we can pass to the
callback.

         // Next populate the PrgCallbackData data structure. The SDK talks
         // about the parameters in a straightforward way so I won't
         // go into them here.
         PrgUpdateDialog (pPrg, 0, wStage, NULL, false);

         // This will call your callback function and do the actual update
of the dialog.
         PrgHandleEvent (pPrg, &event);
}
      else
{
         // If you tap on the cancel button on the progress dialog, it will
be handled here.
   PrgHandleEvent (pPrg, &event);

   if (PrgUserCancel (pPrg))


      PrgStopDialog (pPrg, true);  // Erase the progress dialog.
      booDone = !booDone;
   }
}
   }

/* End of function ****************************************************/


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jason
Simpkins
Sent: Friday, March 10, 2000 12:34 PM
To: Palm Developer Forum
Subject: Re: twiddle thumbs in long computations?


Progress Bar?  Where? When? How?
Jason

----- Original Message -----
From: "Aaron Ardiri" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Friday, March 10, 2000 9:34 AM
Subject: Re: twiddle thumbs in long computations?


> > I have an application that prompts the user for some action, then spends
> > about thirty seconds doing public-key-cryptography operations, and then
> > responds.  I'd like to have some indication on the screen that the
machine
> > is not dead, like a moving clockface, or a progress bar, or something.
Does
> > anyone have any sample code, or hints, or whatever, that they can send
me?
>
>   DONT do it.
>
>   this is anti ZEN of palm :) you could you a progress bar, and it
>   is available in the SDK. but please, do not use a hour glass. :)
>
> az.
> --
> Aaron Ardiri
> Java Certified Programmer      http://www.hig.se/~ardiri/
> University-College i G�vle     mailto:[EMAIL PROTECTED]
> SE 801 76 G�vle SWEDEN
> Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
> Mob: +46 70 656 1143           A/H: +46 8 668 78 72
>
> if you enjoy it, then it aint work :) - rule #106 of life
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
>
>


--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html



--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html




-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to