Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Standard File and Desk Accessories Message-ID: <7547@hoptoad.uucp> Date: 6 Jun 89 01:34:32 GMT References: <50967@tut.cis.ohio-state.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 38 In article <50967@tut.cis.ohio-state.edu> Todd A Hitt writes: >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. Yes, strangely enough, Standard File sets its dialog's refCon to one and then crashes if it's changed. Maybe someone at Apple could enlighten us as to the reasons. Globals can be used in desk accessories. It's pretty easy with LightSpeed C, but fairly tricky with MPW C. If you really can't do this, then there are some other tricks. One thing would be to save the contents of one byte of ApplScratch or ToolScratch before going into Standard File, then setting it from inside Standard File, then extracting it after leaving and restoring the old value. Another way is to write directly into your DA's code space, using PC-relative instructions. This is pretty easy in assembly. The above approaches also have a decent chance of breaking on future systems.... Probably the best way is to use your DA's dCtlStorage field, or your DA window's refCon. The dCtlStorage field will be a bit tricky to get at inside the Standard File hook, but you should be able to find your dialog window very easily, and so find its refCon -- it's the nextWindow field of the Standard File dialog. (Some sophisticated approaches to DA windows might change that, but for most DAs, you will always be bringing up Standard File right in front of the DA window.) -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "Women's wages are 56% of men's -- but that's not necessarily evidence of discrimination in employment." -- Clayton Cramer in news.groups and soc.women