Board index » cppbuilder » Getting file icons - Quicker Way?

Getting file icons - Quicker Way?

I have a ListBox of the OwnerDrawFixed style that the user can drag files
and folders into from Explorer, Net Hood, etc. The ListBox's OnDrawItem
Event and gets the appropriate icon for each file/folder using
ShGetFileInfo, adds it to the line and places the path text next to it. All
this works fine on the local machine, but is slow when dragging files over a
network. Each time you add/remove a file/folder the list box refreshes and
it has to retrieve each icon again.  It's so slow that it's unusable, and if
I can't fix it I'll have to drop the icon bit altogether and just list the
file/folder names.

Is there a way to get around this? Perhaps somehow caching the icons
somewhere so that they only have to be retrieved once? I've tried to get the
right icons from the local machine even if they are dragged in, but often I
don't have the "dragged in" file loaded locally.

Thanks,

Jerry

__________________________

You must offer heartfelt and public condolences over the death of someone's
cat,
even if it was you who secretly set it on fire and threw it into a ceiling
fan.

 

Re:Getting file icons - Quicker Way?


Quote
Jerry Dunn <dddsw> wrote in message news:3bd89d5d_2@dnews...
> I have a ListBox of the OwnerDrawFixed style that the user can drag
files
> and folders into from Explorer, Net Hood, etc. The ListBox's
OnDrawItem
> Event and gets the appropriate icon for each file/folder using
> ShGetFileInfo, adds it to the line and places the path text next to
it. All
> this works fine on the local machine, but is slow when dragging
files over a
> network. Each time you add/remove a file/folder the list box
refreshes and
> it has to retrieve each icon again.  It's so slow that it's
unusable, and if
> I can't fix it I'll have to drop the icon bit altogether and just
list the
> file/folder names.

Jerry, I haven't done this, but there must be a faster way.  Does your
ListBox have it's *own* imagelist, or are you getting them from the
SystemImageList?  Have you read these messages?:
http://www.mers.com/MERLIST/BORLAND/PUBLIC/DELPHI/VCL/COMPONENTS/USIN...

http://www.mers.com/MERLIST/BORLAND/PUBLIC/CPPBUILDER/VCL/43085.HTML
(word-wrap warning for link)

Since you say it works well on the local machine, the COM overhead of
SHGFI is not the culprit, it's the chance for an icon in the file to
override the associated icon;  The remote file has to be opened, even
if there's no icon there after all.  As Damon says in his message,
associating the icon yourself (in a table) would speed things up.
It's essential that you not call SHGFI every-time-each-item is
painted. I guess my own network is very lightly loaded, because I
hardly see network delays.

Perhaps you'll get a better answer in .winapi, since that's really
what this is.  I'm not to well-qualified to help you, but I suggest
you post a little code.
--
Timothy H. Buchman
========================================
City Center Theater, New York NY
mail address tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Search .borland message archive on http://www.mers.com/searchsite.html

Other Threads