Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!apple.com!casseres From: casseres@apple.com (David Casseres) Newsgroups: comp.sys.mac.programmer Subject: Re: How do you write a bg only/faceless app? Message-ID: <12126@goofy.Apple.COM> Date: 15 Feb 91 23:30:28 GMT References: <1991Feb14.150442.1@gsbacd.uchicago.edu> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 37 In article <1991Feb14.150442.1@gsbacd.uchicago.edu> gft_robert@gsbacd.uchicago.edu (opcode ranger) writes: > What are the issues involved in making an app "background only". To write a faceless background app (FBA): first of all, rip out everything that has to do with windows or menus. Don't forget to rip out things like InitWindows, and don't forget that dialogs and alerts are windows too. Write an event loop that doesn't expect to get things like mouse events. Just like any application, an FBA must call WaitNextEvent as often as possible to yield control to Multifinder so other code can run. When the system is shut down, your FBA will be shot down unceremoniously, whatever its state may be. Therefore, make sure you are not midway through editing a file or something when you yield. Documentation says faceless background apps should be "small," but doesn't say what that means. I run 4 different ones simultaneously, ranging up to about 512K. The rest is done in the SIZE resource. Set "can background" and "only background" (these are ResEdit's names for the bits, Rez has different ones just to be weird). I also set "does activate on FG switch," but this is probably unnecessary. I also set "32 bit compatible," since my code is, and I leave all the other bits off. Debugging can be tricky. I recommend building your application with a minimal user interface so you can at least see when it's actually running, and using conditional compilation to take the user interface out when you are satisfied that the rest of the program runs correctly. The above applies to System 6.0x. System 7.0 provides somewhat better support but can also be slightly more demanding; I won't go into detail here because I'm not quite sure what's been announced and what has not. David Casseres Exclaimer: Hey!