[futurebasic] Re: [FB] Custom Icon in DataBrowser -->> Icon+Text Type

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2010 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Fri, 1 Jan 2010 11:13:40 +0000
Deb Lake wrote:

> Does anyone have  a snippet for using a custom (non-System) icon (icns file) with the _kDataBrowserIconAndTextType type in the DataBrowser Example included with FB 5.x? I suspect the icon may need to be registered first or otherwise acknowledged, but my code for that is Resource based and other attempts have been a wash. 


I don't know if this way is recommended but try adding these code bits in appropriate places in your app:

// 1
include "Tlbx MoreFilesX.incl"
include "Tlbx IconsCore.incl"

// 2
include resources "MyIcon.icns"

// 3
_kMyIconType = _"IcnT"

// 4
local fn RegisterIcon( filename as CFStringRef, iconType as OSType )
'~'1
dim as CFURLRef   url
dim as FSRef      ref
dim as IconRef    icon

url = fn CFBundleCopyResourceURL( fn CFBundleGetMainBundle(), filename, 0, 0 )
long if ( url )
long if ( fn CFURLGetFSRef( url, @ref ) )
fn RegisterIconRefFromFSRef( _kSystemIconsCreator, iconType, @ref, @icon )
end if
CFRelease( url )
end if
end fn

// 5 - browser initialisation
fn DBDataSetIconID( browser, _kIconTextPropID, itemID, _kMyIconType )

// 6 - app init
fn RegisterIcon( @"MyIcon.icns", _kMyIconType )


Bernie