Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!petunia!polyslo!rcfische From: rcfische@polyslo.CalPoly.EDU (Raymond C. Fischer) Newsgroups: comp.sys.mac.programmer Subject: Re: Help! Message-ID: <25ff4e70.643e@polyslo.CalPoly.EDU> Date: 15 Mar 90 08:12:32 GMT References: <45183.25FD20CE@cmhgate.FIDONET.ORG> Reply-To: rcfische@polyslo.CalPoly.EDU (Raymond C. Fischer) Organization: Cal Poly State University -- San Luis Obispo Lines: 30 In article <45183.25FD20CE@cmhgate.FIDONET.ORG> Andrew.Lindsey@f563.n107.z1.FIDONET.ORG (Andrew Lindsey) writes: >As part of a project I am working on, I am trying to write an INIT which >will put a program in memory which the user can call up at any time by >clicking on an icon on the menu bar. I have seen this kind of thing done >before, but I can't figure out just how to do it! Does anyone have any >suggestions? INITs are code resources that are loaded into memory _once_ during startup and executed. Most INITs make some changes to the Mac and install some of their own code as part of the startup so that they can get control later and do some nifty stuff. In the INIT I wrote, I had it load code into the system heap and patched a couple traps so that the code would execute later. In your case, you need to figure out how to keep the icon displayed in the menu, even when the menu gets re-drawn. Then you might want to look at hooking into GetNextEvent so that you can intercept mouse downs and see if they're on your icon. Once you know how to do this, write code to handle the events, then write an INIT to install your code someplace and viola! Simple, eh? What you're proposing is not simple Mac programming; applications are easier. Look at the manuals for your development system for guidance on writing code resources. Alternatively, read up on MultiFinder and see if what you want to do is possible with an ordinary application. Ray Fischer rcfische@polyslo.calpoly.edu