ted@hpwrce.HP.COM ( Ted Johnson) (02/01/89)
>Does anyone have a version of the Pascal code found in tech note #126 >(regarding sublaunching an application) written in Lightspeed C? I've >tried to translate it into Lightspeed C and get it to work as advertised >but was unsuccessful so far (we have Multifinder 6.0, if that's important). >The goal is to have a way to launch another application and return to the >launching program; if there's an easier way to do this, I'd be happy to I have the LSC code which shows how to launch another program, but you *can't* go back to the original program (at least with my code :-) -Ted
ted@hpwrce.HP.COM ( Ted Johnson) (02/09/89)
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 <WindowMgr.h> #include <QuickDraw.h> #include <MacTypes.h> #include <EventMgr.h> #include <MenuMgr.h> #include <StdFilePkg.h> 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); } }