home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 21973 < prev    next >
Encoding:
Text File  |  1993-01-23  |  2.6 KB  |  101 lines

  1. Path: sparky!uunet!olivea!bu.edu!bumetb.bu.edu!cpackard
  2. From: cpackard@bumetb.bu.edu (Charles Packard)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: drag and drop example
  5. Message-ID: <107994@bu.edu>
  6. Date: 22 Jan 93 20:17:29 GMT
  7. Sender: news@bu.edu
  8. Organization: Boston University
  9. Lines: 89
  10. Originator: cpackard@bumetb.bu.edu
  11.  
  12. Howdy folks,
  13.  
  14. Could someone clue me in on what magic it takes to get the FINDER
  15. to knonw that I've updated the FREF resource of my application to
  16. add more filetypes to those I want to support drag and drop? I've
  17. twice now written app's that drag and drop just the fine the 
  18. filetypes I've added to the FREF first. But, now I can't get the
  19. FINDER to pass on (with GetAppFiles) other filetypes. 
  20.  
  21. I would appreciate the help folks. Here is some simple code that works
  22. with Think C v5. I've also got it working with SIOW and MPW, though
  23. that was a LOT harder since it was my first time with SIOW!
  24.  
  25. --------------------------------------------start of code
  26. #include <quickdraw.h>
  27. #include <Files.h>
  28. #include <standardfile.h>
  29. #include <SegLoad.h>
  30.  
  31. #include <stdio.h>
  32.  
  33.  
  34. char *Pascal2CString( unsigned char *pstr ) 
  35. {
  36.     register unsigned char *c, *n;
  37.     unsigned char *end=pstr+pstr[0];
  38.     
  39.     for ( c=pstr, n=pstr+1 ; c < end ; *c++ = *n++ )
  40.         ;
  41.         
  42.     *c = '\0';
  43.     return (char *)pstr;
  44. }
  45.  
  46. void main ( void )
  47. {
  48.     short doWhat;       /* for CountAppFiles */
  49.     short fileCnt;
  50.     
  51.     short index;        /* into files selected */
  52.     
  53.     AppFile fileStuff;
  54.     char *cp = (char *) &fileStuff.fType;
  55.  
  56.     Str255 apName;      /* for GetAppParms */
  57.     short resRefNum;
  58.     Handle hParms;
  59.  
  60.     GetAppParms ( apName, &resRefNum, &hParms );
  61.     printf("Application '%s'\n", Pascal2CString( apName ) );
  62.  
  63.     CountAppFiles( &doWhat, &fileCnt );
  64.  
  65.     if ( fileCnt > 0 ) {
  66.         for ( index=1 ; index <= fileCnt ; index++ ) {
  67.             printf("index: %d\n", 1);
  68.             GetAppFiles( index, &fileStuff );
  69.             
  70.             printf("index: %d, Type: '%c%c%c%c', name: '%s'\n",
  71.                 index, cp[0], cp[1], cp[2], cp[3], 
  72.                 Pascal2CString( fileStuff.fName ) );
  73.             ClrAppFiles( index );
  74.         }
  75.         
  76.         if ( doWhat == appOpen ) {
  77.             /*
  78.              * open up the files selected in Finder
  79.              */
  80.         } else if ( doWhat == appPrint ) {
  81.             /*
  82.               * print files selected in Finder
  83.               */
  84.          } else {
  85.              /*
  86.               * not expecting any other value back from CountAppFiles
  87.               */
  88.              exit (1);
  89.          }
  90.     } else {
  91.         printf("No files selected.\n");
  92.     }
  93. }
  94. --------------------------------------------end of code
  95.  
  96. regards,
  97. chuck packard
  98. cpackard@mathwors.com        <-- if responding directly to me use this
  99.                                  address as I will soon lose my BU feed, thanks
  100.                                  
  101.