Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!schooner.cis.ohio-state.edu!thitt From: thitt@schooner.cis.ohio-state.edu (Todd A Hitt) Newsgroups: comp.sys.mac.programmer Subject: Re: Standard File and Desk Accessories Message-ID: <51276@tut.cis.ohio-state.edu> Date: 7 Jun 89 02:54:44 GMT References: <50967@tut.cis.ohio-state.edu> <7547@hoptoad.uucp> <4972@umd5.umd.edu> Sender: news@tut.cis.ohio-state.edu Reply-To: Todd A Hitt Organization: Ohio State University Computer and Information Science Lines: 61 Thanks for all your ideas on Desk Accessories & (non)Standard-File. For a few of you who have asked why I can't use globals it's because I have a DA that's mostly in MPW Pascal and somewhat in MPW C. Neither one of these environments provide "official" support for globals in DA's. I'm sure someone from Symantec can enlighten us but I think they get around this problem by using another register (maybe A4?) to "anchor" the global variables. I believe that applications have their globals referenced by A5. But enough of that. Here's the solution or part of it, I used (and it works) that was sent to me by Krzysztof Kozminski: >In article <50967@tut.cis.ohio-state.edu> you write: >>Has anybody used a non-standard dialog box with SFPPutFile? I would like >>to add a check box to the bottom of my PutFile dialog box. In my dlgHook >>procedure I can toggle this item, but...how does one get the status of >>whether the check box was checked after SFPPutFile returns? >> >>I can't use a global variable in a Desk Accessory. I've tried using the >>dialog's refCon - which causes Standard File to crash. > >I am not sure how you are going to use dialog's refCon - I don't think >you can get at your DialogPtr before or after calling CFPPutFile ... > >Anyway, just an idea, based on what I do: > > long **h = NewHandle(4); > int checkBoxValue; > > **h = (long) &checkBoxValue; > AddResource(h,'pvte',0,"\p"); > > /* Now you have a private resource (in whatever is the current > resource file) that stores the address of your result. */ > > SFPPutfFile( ..., myHook, ...); > > /* my Hook calls GetResource(...'pvte',0...) to find out where to > put the value of the check box control. */ > > RmveResource(h); /* Don't want it added to, e.g., System */ > [stuff deleted] I've modified it a little to suit me but it works like a champ. I do feel a little funny using the resource manager like this, but it doesn't look like there is any particularly clean way to do this. Thanks Krzysztof! = = = = = = = = = = Todd Hitt thitt@cis.ohio-state.edu Battelle Columbus/Ohio State University hitt%36.114@ohstpy.mps.ohio-state.edu (614)424-3297 "You were not put on this earth to 'Get It'" - "Lo Pan" in Big Trouble in Little China -=- = = = = = = = = = = Todd Hitt thitt@cis.ohio-state.edu