Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-ses!hpcc01!hpwrce!ted From: ted@hpwrce.HP.COM ( Ted Johnson) Newsgroups: comp.sys.mac.programmer Subject: Re: launching question Message-ID: <7430005@hpwrce.HP.COM> Date: 9 Feb 89 09:43:41 GMT References: <26471@teknowledge-vaxc.ARPA> Organization: HP North American Response Center Lines: 86 Someone asked me for this, but e-mail to him bounced. -Ted ----cut here------- /* *Program name: Launch (Transfer) Demo * *Author: Ted C. Johnson, Tues, March 1, 1988. I got this guts of this code * from the June 1987 issue of MacTutor magazine, p24. * *Compilation instructions: use Lightspeed C, v.2.15. This program does * NOT use any resource files. This program was * developed on a Mac SE HD20 running System/Finder * 4.1/5.5. * * *Summary: This program is a demonstration of how to use the Launch() trap * to launch one program from inside of another program. This is * usually implemented as a "Transfer..." menu item under the "File" * menu. * * The advantage of doing this is that someone can go from one * program to another without having to return to the Finder (which * takes a while, because the Finder is just an applications program * itself, and it takes time to start up). Of course, this is not * necessary if you are using Switcher or MultiFinder! */ #include #include #include #include #include #include SFReply theReply; SFTypeList myTypes; Point SFDialogOrigin; OSErr ErrorCode; main() { /*Initialize stuff.*/ InitGraf(&thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(0L); /*Remove all events from the event queue.*/ FlushEvents(everyEvent, 0); /* *Usually there is a "Transfer..." menu item on the "File" menu, but *for the sake of brevity, I am skipping all that. This program just *puts up a Standard File dialog (which only shows applications, not *documents!), and then launches the program that the user selects. *If the user selects cancel, then the program will quit and return *to the Finder. */ myTypes[0] = 'APPL'; SetPt(&SFDialogOrigin, 80, 80); SFGetFile(SFDialogOrigin, "\p", 0L, 1, myTypes, 0L, &theReply); if (theReply.good == TRUE) { ErrorCode = SetVol(0L, theReply.vRefNum); Launch(0, &theReply.fName); } }