Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File association icons
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00728027
Message ID:
01045420
Vues:
26
Nadya (still OK or better Naomi?)!

> Once you have this picture, how can you display it in a grid? E.g. I've
> implemented the ListView interface using your IconBuddy and MS ListView
> samples, but I don't like the look. My manager also wants it grid based
> (perhaps he doesn't care about the icons at all, but I'd like to have
> them). Any idea of using your class with grids rather than with ListView?

( - this is just a copy from our PM from yesterday - just to have it here in the UT - )

Actually it's been quite some time, I touched Iconbuddy, but... hmm.... The problem is, You can't use icon objects in a grid like You would in a TreeView or ListView.


How about saving the icon to a tempfile and use this instead. You could have a cursor that holds information what Iconfile to use for witch associated filetype. In the destroy You could delete all the temporary icons. No, maybe better use a collection. Maybe something like this (just some pseudocode I will write down but I'm sure You get the drift)


Methods from Iconbuddy that could be useful for You are: Save2File() as well as GetAssocIconObject() as well as GetAssocIconPairObjects()

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
something like this. Once You've loaded the filetypes needed into the collection You could use GetIconFile([, ]) from within the grid to query the tmp-Filename for a given extension.

Hope this works for You. As I said, I just wrote this down. But I think it should work
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform