How to Display a Progress Bar
How to Display a Progress Bar
/* How to Display a Progress Bar */
/* This is a simple example of how to display a status bar progress bar */
// Assumes inclusion of
main()
{
DialogPtr barDlogPtr;
short itemType;
Handle iHndl;
Rect box;
short i,
old_right;
float limit;
long counter;
InitGraf(&thePort);
barDlogPtr = GetNewDialog(128, nil, (WindowPtr)-1L);
SetPort(barDlogPtr);
GetDItem(barDlogPtr,1,&itemType,&iHndl,&box);
FrameRect(&box);
old_right = box.right;
limit = (box.right - box.left)/36.0; /* use a float to get good*/
while(1) [TOKEN:12074] accuracy*/
{
for(i = 1; i<=36 ;i++)
{
box.right = box.left + i*limit;
FillRect(&box,gray);
Delay(10L,&counter); /* you won't need this! */
if(Button())
{
DisposDialog(barDlogPtr);
return;
}
}
box.right = old_right; [TOKEN:12074] since there is round off error*/
FillRect(&box,gray); [TOKEN:12074] when we get close, */
Delay(20,&counter); [TOKEN:12074] wait a 1/3 of a second*/
FillRect(&box,white); /* and get back to the original*/
FrameRect(&box);
}
}
/* Rez file for the DLOG and DITL resources used by the progress dialog */
#include "Types.r
resource 'DITL' (128) {
{ /* array DITL array: 1 elements */
/* [1] */
{68, 8, 96, 340},
UserItem {
enabled
}
}
};
resource 'DLOG' (128) {
{46, 81, 296, 431},
dBoxProc,
visible,
noGoAway,
0x0,
128,
};