Andre Augusto wrote:
> Can anyone tell me where can I find some code regarding progress bar,
> especialy in C language, to use with codewarrior?

Here's the general idea.  If you want to add decorations, you can
draw text with WinDrawChars() and put a frame around it with
WinDrawRectangleFrame() with maybe boldRoundFrame frame type or
something.

  - Logan

--------------------------------------------------------------------------


typedef struct
{
    RectangleType bounds;
    WinHandle savedbits;
} ProgBar;

void OpenProgressBar (ProgBar *progbar)
{
    UInt16 savebitserror;

    progbar->savedbits = WinSaveBits (& progbar->bounds, & savebitserror);
    WinEraseRectangle (& progbar->bounds, 0);
}

void CloseProgressBar (ProgBar *progbar)
{
    if (progbar->savedbits)
    {
        WinRestoreBits (
                progbar->bounds.topLeft.x, progbar->bounds.topLeft.y,
                progbar->savedbits);
    }
    else
    {
        /* maybe should enqueue a frmUpdateEvent instead, maybe not */
        WinEraseRectangle (& progbar->bounds, 0);
    }
}

void UpdateProgressBar (ProgBar *progbar, Int32 numerator, Int32 denominator)
{
    RectangleType fillrect;

    RctCopyRectangle (& progbar->bounds, & fillrect);
    fillrect.extent.x = progbar->bounds.extent.x * numerator / denominator;

    WinDrawRectangle (& fillrect, 0);
}

void TestProgressBar ()
{
    Int32 i;
    const Int32 max = 25;
    ProgBar progbar;

    progbar.bounds.topLeft.x = 20;
    progbar.bounds.topLeft.y = 70;
    progbar.extent.x = 120;
    progbar.extent.y = 20;

    OpenProgressBar (& progbar);
    for (i = 0; i <= max; i++)
    {
        UpdateProgressBar (& progbar, i, max);
        SysTaskDelay (SysTicksPerSecond() / 5);
    }
    CloseProgressBar (& progbar);
}

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

Reply via email to