GetMultiple.c

By Kyle Hammond
kyle [dot] hammond [at] snowmintcs [dot] com


Please note that this code is very nice if you're programming for Mac OS 7.x - 9.x. If you're doing programming for Mac OS X, there are much more modern solutions that Apple provides for you to use.

This archive contains code that uses CustomGetFile to grab more than one file at a time. If you need to ask the user for multiple files at one time, this is a simple way to add that functionality to your project.

The interface design came directly from Metrowerks Codewarrior's Add Multiple... command. However, I wrote all of the code...almost. The code is actually based on GetFolder.c which is an old (no longer available) sample from Apple's Developer Connection.

This code can make use of my List Manager substitute, The A List, or Apple's List Manager.


Calling The Function

Add the file GetMultiple.c and the DLOG, DITL and dlgx resources in GetMultiple.rsrc to your project.

Calling the function is quite simple. The function prototype is:

long CustomGetMultiple( FSSpecPtr outFSSpecArray, long inMaxReturned, FileFilterUPP inFileFilterUPP, ModalFilterUPP inModalFilterUPP );
outFSSpecArray
a pointer to an array of FSSpecs that will be filled upon return.
inMaxReturned
the maximum number of FSSpecs to return (the size of the outFSSpecArray array).
inFileFilterUPP
a standard file filter that will be called to check if the file should be displayed.
inModalFilterUPP
a standard modal dialog filter that will be called to handle things like update events.

The returned value is equal to the number of valid FSSpecs in the outFSSpecArray array. It will be zero if the user chose no files or clicked cancel.

Use Either The A List or Apple's List Manager

CustomGetMultiple defaults to using The A List, but can use Apple's List Manager instead. There is a #define at the top of GetMultiple.c that switches between the two. Set GETMULTIPLE_USE_ALIST to any non-zero value to use The A List (this is the default setting). Set GETMULTIPLE_USE_ALIST to zero in order to use Apple's List Manager.

Wish List

The list of selected files does not draw the file icons. I know there is code floating around that I could use to do that, but I don't have the time or the inclination to do it myself. If somebody wants to do that and email it back to me, I'd be happy to include it.

Add keyboard support when using Apple's List Manager. It just seemed like a lot of busy work so I haven't done it yet. If somebody else does that, please send me the source and I'll include it in the file here.

Note: These things will probably never get done because I don't program for Mac OS 7.x - 9.x anymore.

Downloads

GetMultiple.hqx - Binhexed compressed source code (9K) - updated 1999-11-20

Acknowledgments

Thanks to Apple DTS for supplying the very nice GetFolder.c (although it's not available for download anymore).

Thanks to Metrowerks Codewarrior for showing how the user interface for getting multiple files should be.

Go to my home page.

Send feedback to kyle [dot] hammond [at] snowmintcs [dot] com