home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!bu.edu!bumetb.bu.edu!cpackard
- From: cpackard@bumetb.bu.edu (Charles Packard)
- Newsgroups: comp.sys.mac.programmer
- Subject: drag and drop example
- Message-ID: <107994@bu.edu>
- Date: 22 Jan 93 20:17:29 GMT
- Sender: news@bu.edu
- Organization: Boston University
- Lines: 89
- Originator: cpackard@bumetb.bu.edu
-
- Howdy folks,
-
- Could someone clue me in on what magic it takes to get the FINDER
- to knonw that I've updated the FREF resource of my application to
- add more filetypes to those I want to support drag and drop? I've
- twice now written app's that drag and drop just the fine the
- filetypes I've added to the FREF first. But, now I can't get the
- FINDER to pass on (with GetAppFiles) other filetypes.
-
- I would appreciate the help folks. Here is some simple code that works
- with Think C v5. I've also got it working with SIOW and MPW, though
- that was a LOT harder since it was my first time with SIOW!
-
- --------------------------------------------start of code
- #include <quickdraw.h>
- #include <Files.h>
- #include <standardfile.h>
- #include <SegLoad.h>
-
- #include <stdio.h>
-
-
- char *Pascal2CString( unsigned char *pstr )
- {
- register unsigned char *c, *n;
- unsigned char *end=pstr+pstr[0];
-
- for ( c=pstr, n=pstr+1 ; c < end ; *c++ = *n++ )
- ;
-
- *c = '\0';
- return (char *)pstr;
- }
-
- void main ( void )
- {
- short doWhat; /* for CountAppFiles */
- short fileCnt;
-
- short index; /* into files selected */
-
- AppFile fileStuff;
- char *cp = (char *) &fileStuff.fType;
-
- Str255 apName; /* for GetAppParms */
- short resRefNum;
- Handle hParms;
-
- GetAppParms ( apName, &resRefNum, &hParms );
- printf("Application '%s'\n", Pascal2CString( apName ) );
-
- CountAppFiles( &doWhat, &fileCnt );
-
- if ( fileCnt > 0 ) {
- for ( index=1 ; index <= fileCnt ; index++ ) {
- printf("index: %d\n", 1);
- GetAppFiles( index, &fileStuff );
-
- printf("index: %d, Type: '%c%c%c%c', name: '%s'\n",
- index, cp[0], cp[1], cp[2], cp[3],
- Pascal2CString( fileStuff.fName ) );
- ClrAppFiles( index );
- }
-
- if ( doWhat == appOpen ) {
- /*
- * open up the files selected in Finder
- */
- } else if ( doWhat == appPrint ) {
- /*
- * print files selected in Finder
- */
- } else {
- /*
- * not expecting any other value back from CountAppFiles
- */
- exit (1);
- }
- } else {
- printf("No files selected.\n");
- }
- }
- --------------------------------------------end of code
-
- regards,
- chuck packard
- cpackard@mathwors.com <-- if responding directly to me use this
- address as I will soon lose my BU feed, thanks
-
-