[futurebasic] Re: [FB] re: FndrFlags, FileAttr etc.

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2003 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Sun, 02 Mar 2003 01:09:10 +0100

Laurent SIEBENMANN wrote:
> Hi all,
> 
> I am still hoping for hints on my 'harder' question
> 
>  > There are further Finder attributes that color code file 
>  > and directory icons -- at least interectively under the 
>  > Finder. CAN WE ACCESS THESE COLOR ATTRIBUTES FROM INSIDE 
>  > FB^3? 
> 
> 

I wonder if I have understood your question, but if you're talking 
about the Finder labels, maybe the following might be a starter (I'm 
not sure it is OK though):

include "Tlbx Icons.Incl"

clear local mode
Local fn SetFileLabel ( spec as .FSSpec, theLabel as int )
dim err       as OSErr
dim theColor  as int
dim fndrInfo  as FInfo

err = fn FSpGetFInfo( #spec, fndrInfo )
long if err = _noErr
select theLabel
case 1 : theColor = 258
case 2 : theColor = 260
case 3 : theColor = 262
case 4 : theColor = 264
case 5 : theColor = 266
case 6 : theColor = 268
case 7 : theColor = 270
case else
theColor = 256
end select
fndrInfo.fdFlags = theColor
err = fn FSpSetFInfo( #spec, fndrInfo )
end if

end fn = err


clear local mode
local fn GetFileLabel( spec as .FSSpec )
dim label     as int
dim fndrInfo  as FInfo

long if fn FSpGetFInfo( #spec, fndrInfo ) = _noerr
select fndrInfo.fdFlags
case 270  : label = 7
case 268  : label = 6
case 266  : label = 5
case 264  : label = 4
case 262  : label = 3
case 260  : label = 2
case 258  : label = 1
case else : label = 0
end select
end if

end fn = label


// test
window 1
dim fSpec       as FSSpec
dim label       as int
dim labelColor  as RGBColor
dim labelString as str255

for label = 1 to 7
long if fn GetLabel( label, labelColor, labelString ) = _noErr
RGBForeColor( labelColor )
print label,labelString
end if
next

long if len(files$(_FSSpecOpen,"","",fSpec))
label = fn GetFileLabel( fSpec )
long if label
long if fn GetLabel( label, labelColor, labelString ) = _noErr
RGBForeColor( labelColor )
print label,labelString
end if
end if
long if fn SetFileLabel( fSpec , 1 ) = _noErr
label = fn GetFileLabel( fSpec )
long if label
long if fn GetLabel( label, labelColor, labelString ) = _noErr
RGBForeColor( labelColor )
print label,labelString
end if
end if
end if
end if

do
handleevents
until _nil

Cheers,

Alain