Eliot.Henry@samba.acs.unc.edu (BBS Account) (08/13/90)
I am trying to make a simple progress bar (like the one the finder uses to let you know what is going on when you copy files) How would the best way to do this be? User Item? Control? What is the official apple suggestion? I would greatly appreciate any source code examples on ho wto do this! Seems such a waste of time to try to figure it out since so many people must use this type of thing. Thanks!
stevec@Apple.COM (Steve Christensen) (08/14/90)
In article <799@beguine.UUCP> Eliot.Henry@samba.acs.unc.edu writes: >I am trying to make a simple progress bar (like the one the finder uses to >let you know what is going on when you copy files) How would the best way to >do this be? User Item? Control? What is the official apple suggestion? I would >greatly appreciate any source code examples on ho wto do this! Seems such >a waste of time to try to figure it out since so many people must use this >type of thing. Well, I don't know what the official Apple suggestion is, but I've done some progress bars from time to time. I usually do them as a userItem, so the code looks something like this (note this is written on the fly, so there could be a small bug or three): { routine to draw a progress bar in a userItem } PROCEDURE DrawProgress(theDialog:DialogPtr; theItem:INTEGER); VAR theRect : Rect; BEGIN GetDRect(theDialog,theItem,theRect); {my utility to get bounding rect} FrameRect(theRect); {put a border around it} InsetRect(theRect,1,1); {inset the rect 1 pixel all around} theRect.right:=theRect.left + {calc right edge of gray bar} (theRect.right-theRect.left) * currValue DIV maxValue; FillRect(theRect,gray); {fill resized rect with gray} END; currValue and maxValue are globals that specify the current and maximum values that whatever you're displaying can take on. Oh, and just for completeness, GetDRect looks like this: { routine to return a dialog item's bounding rectangle } PROCEDURE GetDRect(theDialog:DialogPtr; theItem:INTEGER; VAR theRect:Rect); VAR theType: INTEGER; theHandle : Handle; BEGIN GetDItem(theDialog,theItem,theType,theHandle,theRect); END; The C implementation is almost identical and is left as an exercise for the reader... :-) steve -- ____________________________________________________________________ Steve Christensen Internet: stevec@goofy.apple.com Apple Computer, Inc. AppleLink: STEVEC 20525 Mariani Ave, MS 81-CS CompuServe: 76174,1712 Cupertino, CA 95014 "You just contradicted me." "No I didn't." ____________________________________________________________________