[futurebasic] [FB^3] Plotting Mounted Volume Icons

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2001 : Group Archive : Group : All Groups

From: Craig Hoyt <aztech4mac@...>
Date: Thu, 27 Sep 2001 21:56:09 -0700
Hi all... About 10 days ago I ask if anyone had code to plot the Icons of
mounted volumes. No one responded on the list and Charlie Dickman provided
some code off list. Unfortunately his code was not helpful in the case but
a cool program none the less. After an embarrassing amount of time (were
talking several days) I realized I was barking up the wrong tree and tonite
tried a different approach. Below is what I came up with. The solution was
much more simple that what I was trying before. The code isn't pretty but
is functional! I hope someone finds this useful. Remember line breaks.


rem Plots All mounted Volume Icons
rem All Hard Drives, CD's, Floppies, Jaz, Zips, even mounted HD's from
networked computers!

include "HFS+.INCL"
include "Tlbx Icons.Incl"

Dim vName$
dim as rect theRect,theRect2
dim IRef&, what, OSErr%, X,gVrefNum%,test

begin RECORD FSSpecRec
DIM fsVRefNum%
DIM fsParID&
DIM 63 fsName$
END RECORD

DIM spec as FSSpecRec

call setrect(theRect,100,20,131,51)
call setrect(theRect2,50,55,180,75)
what=0
window #1,"ANY KEY TO EXIT'
text 0,12,0,0:X=0
 do
inc(X)'Inc index
test=fn ValidVolume(X)'Check for valid Volume
if test=0 then X=1:test=fn ValidVolume(X%)'If no reset to 1
vName$=fn GetVolumeName$(X)'Get Volume Name
gVrefNum%=fn GetVolumeRefNum(X)' Get Volume RefNum

spec.fsVRefNum%=-gVrefNum%'Setup fileSpec using Volume info
spec.fsParID&=1
spec.fsName=vName$

OSErr%=fn geticonreffromfile (@spec,@IRef&,@what)' Get the Icon

color 0:call paintrect(theRect):color 7'Clear old Icon
OSErr%=fn
ploticonref(@theRect,_kAlignNone,_kTransformNone,_kIconServicesNormalUsageFlag,I
Ref&)'Plot New Icon
DEF CBOX (theRect2, vName$)'Print Volume Name

handleevents:delay 200

if peek(388)>0 then end
until 1=0

Thanks to all that tried, especially Charlie.
Craig


======================================================================
Aztech Professional On-Site Service

* Craig Hoyt
* Phone: 818-773-0864   Fax: 818-773-0675
* E-mail: craig@...
* Web: http://www.aztech4mac.com

Macintosh Technology Solutions Since 1984
=======================================================================