home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!darwin.sura.net!jvnc.net!rutgers!ub!csn!news.den.mmc.com!sorchard@crowded-house.den.mmc.com
- From: sorchard@crowded-house.den.mmc.com (Steve Orchard)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Launching from a document file
- Message-ID: <1992Sep14.141511.4522@den.mmc.com>
- Date: 14 Sep 92 14:15:11 GMT
- References: <47491@shamash.cdc.com>
- Sender: news@den.mmc.com (News)
- Distribution: usa
- Organization: Martin Marietta
- Lines: 60
- Nntp-Posting-Host: lsc_mac_1
-
- In article <47491@shamash.cdc.com>, paul@svl.cdc.com (Paul Kohlmiller) writes:
- >
- > I am successfully launching applications via LaunchApplication.
- > The problem what I would really like to do is launch from a
- > document not from the application file itself. I want to be able
- > to do the equivalent of double-clicking a MSWord document and have it
- > come up with that document open. I think I need something like
- > LaunchApplicationwithOpenFile but I don't see this in IM Processes or
- > IM Files (on CD). Getting the application name from the document file
- > is probably not too hard but how do I get it to launch the app and open
- > the file, too?
- > thnx
-
- You must set the Finder Information first and then launch the Application.
- Below is the code I use to do this for system 6. For system 7 and beyond
- use AppleEvents. Check out the code snippet on ftp.apple.com.
-
-
- typedef struct
- {
- int message; /* Open = 0, Print = 1 */
- int count; /* Number of docs selected. */
- AppFile findinfo; /* AppFile structure */
- } **FindrInfo;
-
- void setfinder(thepath,num)
- Str255 thepath;
- int num;
- {
- OSErr err;
- FindrInfo finderstuff;
- FInfo finfo;
- int i,strsize;
- AppFile *temp;
-
- err = GetFInfo(thepath,0,&finfo);
- HUnlock(AppParmHandle);
- if(num==1)
- SetHandleSize(AppParmHandle,(Size)(sizeof(AppFile)+4));
- else
- SetHandleSize(AppParmHandle,(Size)(sizeof(AppFile))+(Size)(sizeof(AppParmHandle)));
- MoveHHi(AppParmHandle);
- HLock(AppParmHandle);
- finderstuff = (FindrInfo)AppParmHandle;
- (**finderstuff).message=0;
- (**finderstuff).count=num;
- temp = &(**finderstuff).findinfo;
- for(i=1;i!=num;i++)
- {
- strsize = *temp->fName + 9;
- if((strsize % 2) != 0) strsize=strsize+1;
- temp=(Ptr)temp + strsize;
- }
- temp->fType=finfo.fdType;
- temp->vRefNum=finfo.fdFldr;
- strcpy(temp->fName,thepath);
- }
-
- Good Luck
- Steve Orchard
-