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

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

From: Alain Pastor <apastor@...>
Date: Fri, 28 Sep 2001 09:52:01 +0200
Craig Hoyt wrote:
> 
> 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.
> 
For those interested, here is a standalone version of Graig's code:

#if def _usingLiteRuntime
print "this prog requires the Standard or the Appearance runtime."
#else

begin record UnsignedWide
dim hh as unsigned word
dim hl as unsigned word
dim lh as unsigned word
dim ll as unsigned word
end record

begin record XVolumeParam
 dim as long           qLink
 dim as short          qType
 dim as short          ioTrap
 dim as long           ioCmdAddr
 dim as long           ioCompletion
 dim as OSErr          ioResult
 dim as long           ioNamePtr
 dim as short          ioVRefNum
 dim as unsigned long  ioXVersion
 dim as short          ioVolIndex
 dim as unsigned long  ioVCrDate
 dim as unsigned long  ioVLsMod
 dim as short          ioVAtrb
 dim as unsigned short ioVNmFls
 dim as unsigned short ioVBitMap
 dim as unsigned short ioAllocPtr
 dim as unsigned short ioVNmAlBlks
 dim as unsigned long  ioVAlBlkSiz
 dim as unsigned long  ioVClpSiz
 dim as unsigned short ioAlBlSt
 dim as unsigned long  ioVNxtCNID
 dim as unsigned short ioVFrBlk
 dim as unsigned short ioVSigWord
 dim as short          ioVDrvInfo
 dim as short          ioVDRefNum
 dim as short          ioVFSID
 dim as unsigned long  ioVBkUp
 dim as short          ioVSeqNum
 dim as unsigned long  ioVWrCnt
 dim as unsigned long  ioVFilCnt
 dim as unsigned long  ioVDirCnt
 dim as long           ioVFndrInfo[7]
 dim as UnsignedWide   ioVTotalBytes
 dim as UnsignedWide   ioVFreeBytes
end record

include "Tlbx Icons.Incl"

local mode
local fn PlotVolumeIcon( r as ^rect, vSpec as ^FSSpec )
  dim @ iconRef as long
  dim @ label   as SInt16

  long if fn GetIconRefFromFile ( #vSpec, iconRef,label ) = _noErr
    long if fn PlotIconRef( #r, _kAlignNone, _kTransformNone,
_kIconServicesNormalUsageFlag, iconRef ) = _noErr
      MoveTo( r.left, r.bottom + usr fontheight )
      DrawString( vSpec.name )
    end if
    label = fn ReleaseIconRef( iconRef )
  end if
end fn

local fn DisplayMountedVolumes
  dim i       as short
  dim volName as str63
  dim r       as rect
  dim pb      as XVolumeParam
  dim vSpec   as FSSpec

  SetRect( r, 0, 0, 32, 32 )
  i = 0
  do
    def blockfill( @pb, sizeof( pb ), 0 )
    i++
    pb.ioVrefNum = -i
    pb.ioNamePtr = @volName
    select fn PBXGetVolInfoSync( pb )
      case _noErr
        OffsetRect( r, 60, 0 )
        vSpec.vRefNum = -i
        vSpec.parID   = 1
        vSpec.name    = volName$
        fn PlotVolumeIcon( r, vSpec )
      case else
        exit fn
    end select
  until _nil
end fn

// Main prog
window 1
fn DisplayMountedVolumes

do
  handleevents
until fn Button
#endif

-- 

Cheers

Alain

-----------------------------------------------------
FB^3 in Europe:  http://euro.futurebasic.com/
FB II Pouch:     http://www.pixmix.com/FB/outils.html
-----------------------------------------------------