>DEFINE Class WhatEver as relation > >oIcons = null >oIconBuddy = null > > >PROCEDURE INIT > this.oIcons = create("collection") > >ENDPROC > >PROCEDURE DESTROY > *-- do some cleanup here > if ! isNull(this.oIcons) and this.oIcons.Count > 0 > for each loItem in this.oIcons > if ! empty(loItem.cIconLarge) and file(loItem.cIconLarge) > > *-- well,... let's try catch here a file might be in use > try > erase (loItem.IconLarge) > > catch > *-- ok leave it there. it's in the tmp-Folder and > *-- will be deleted upon system maintennance or we > *-- do have a routine that *does* check for older > *-- rubbish > > endtry > > endif && ! empty(loItem.cIconLarge.... > > if ! empty(loItem.cIconSmall....... > *-- the same for the small icon here > ..... > > endif > > endfor > endif > > this.oIconbuddy = null > this.oIcons = null > >ENDPROC > > >PROCEDURE CreateTMPIcon(tcFile as string) as boolean > local lcExtension, loItem, ..... > > *-- Get the extension of the given file > lcExtension = lower(justExt(tcFile)) > > *-- and see if we already have an icon for it > lcIconFile = this.GetIconFile(lcExtension) > > if empty(lcIconFile) > *-- Not in the collection yet > > loItem = create("EMPTY") > addProperty(loItem, "cIconLarge", "") > addProperty(loItem, "cIconSmall", "") > > *-- now extract the icons for the filetype > loIconLarge = .null. > loIconSmall = .null. > > lnIconsFound = this.oIconBuddy(tcFile, @loIconLarge, @loIconSmall) > > if lnIconsFound = 2 > *-- Save the IconObject to disk > lcOutStem = "ICN"+ sys(2015) > lcOutFile = addBS(sys(2023)) + lcOutStem + "_L.ICO" > > this.oIconBuddy.Save2File( loIconLarge, lcOutFile ) > > *-- and keep for further reference > loItem.cIconLarge = lcOutFile > > *-- Do the same with the small icon > lcOutFile = addBS(sys(2023)) + lcOutStem + "_S.ICO" > this.oIconBuddy.Save2File( loIconSmall, lcOutFile ) > > *-- and keep for further reference > loItem.cIconSmall = lcOutFile > > endif > > *-- ... finally add the Item to the Collection > this.oIcons.Add( loItem, lcExtension ) > endif > >ENDPROC > > >PROCEDURE GetIconFile(tcExtension as String, tlLargeIcon as boolean) as String > *-- See if we have an Icon for that extension in our > *-- collection and if so, return the filename to it > > local lcRetVal, lcExtension, lnItem > > lcRetVal = "" > lcExtension = lower(tcExtension) > > if ! isnull(this.oIcons) and this.oIcons.count > 0 > > lnItem = this.oIcons.GetKey(lcExtension) > > if lnItem > 0 > *-- Yep! found it > lcRetVal = iif(tlLargeIcon, this.oIcons(lnItem).cIconLarge, this.oIcons(lnItem).cIconSmall) > > endif > > endif && ! isnull(this.oIcons.... > > return lcRetVal > >ENDPROC > > >ENDDEFINE >>