home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15439 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  2.3 KB

  1. Path: sparky!uunet!gatech!darwin.sura.net!jvnc.net!rutgers!ub!csn!news.den.mmc.com!sorchard@crowded-house.den.mmc.com
  2. From: sorchard@crowded-house.den.mmc.com (Steve Orchard)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Launching from a document file
  5. Message-ID: <1992Sep14.141511.4522@den.mmc.com>
  6. Date: 14 Sep 92 14:15:11 GMT
  7. References: <47491@shamash.cdc.com>
  8. Sender: news@den.mmc.com (News)
  9. Distribution: usa
  10. Organization: Martin Marietta
  11. Lines: 60
  12. Nntp-Posting-Host: lsc_mac_1
  13.  
  14. In article <47491@shamash.cdc.com>, paul@svl.cdc.com (Paul Kohlmiller) writes:
  15. > I am successfully launching applications via LaunchApplication.
  16. > The problem what I would really like to do is launch from a
  17. > document not from the application file itself. I want to be able
  18. > to do the equivalent of double-clicking a MSWord document and have it
  19. > come up with that document open. I think I need something like
  20. > LaunchApplicationwithOpenFile but I don't see this in IM Processes or
  21. > IM Files (on CD). Getting the application name from the document file
  22. > is probably not too hard but how do I get it to launch the app and open
  23. > the file, too?
  24. > thnx
  25.  
  26. You must set the Finder Information first and then launch the Application.
  27. Below is the code I use to do this for system 6.  For system 7 and beyond
  28. use AppleEvents.  Check out the code snippet on ftp.apple.com.
  29.  
  30.  
  31. typedef struct
  32. {
  33.     int            message;    /* Open = 0, Print = 1 */
  34.     int            count;        /* Number of docs selected. */
  35.     AppFile        findinfo;    /* AppFile structure */
  36. } **FindrInfo;
  37.  
  38. void setfinder(thepath,num)
  39. Str255    thepath;
  40. int        num;
  41. {    
  42.     OSErr                err;
  43.     FindrInfo            finderstuff;
  44.     FInfo                finfo;
  45.     int                    i,strsize;
  46.     AppFile                *temp;
  47.         
  48.     err = GetFInfo(thepath,0,&finfo);
  49.     HUnlock(AppParmHandle);
  50.     if(num==1)
  51.         SetHandleSize(AppParmHandle,(Size)(sizeof(AppFile)+4));
  52.     else
  53.         SetHandleSize(AppParmHandle,(Size)(sizeof(AppFile))+(Size)(sizeof(AppParmHandle)));
  54.     MoveHHi(AppParmHandle);
  55.     HLock(AppParmHandle);
  56.     finderstuff = (FindrInfo)AppParmHandle;
  57.     (**finderstuff).message=0;
  58.     (**finderstuff).count=num;
  59.     temp = &(**finderstuff).findinfo;
  60.     for(i=1;i!=num;i++)
  61.     {
  62.         strsize = *temp->fName + 9;
  63.         if((strsize % 2) != 0) strsize=strsize+1;
  64.         temp=(Ptr)temp + strsize;
  65.     }
  66.     temp->fType=finfo.fdType;
  67.     temp->vRefNum=finfo.fdFldr;
  68.     strcpy(temp->fName,thepath);
  69. }
  70.  
  71. Good Luck
  72. Steve Orchard
  73.