Article View: borland.public.cppbuilder.nativeapi
Article #4148Re: Getting SYS Icons
From: Remy Lebeau (TeamB)
Date: Fri, 10 Mar 2006 01:02
Date: Fri, 10 Mar 2006 01:02
93 lines
4277 bytes
4277 bytes
"poojo hackma" <poojo.com/mail> wrote in message
news:4410abd3@newsgroups.borland.com...
> My OnCustomDrawItem handler below is still messy, but it's working!
You are misusing that event. One of the things you are doing is using that
event to assign the TListItem::ItemIndex property for your FTP items. That
is the completely wrong place to do that. You should be setting it at the
time you add the item to the ListView, or alternatively in the
OnGetImageIndex event (which is a better choice for virtual ListViews). The
OnCustomDrawItem event is only to be used for drawing and nothing else.
Use this code instead:
void __fastcall TMainForm::ListView_GetImageIndex(TObject* Sender,
TListItem* Item)
{
SHFILEINFO FileInfo = {0};
int Flags = ( SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON );
int Attrs;
AnsiString temp;
char *p;
TListView* lv = static_cast<TListView*>(Sender);
if( lv == lvFtp )
{
Attrs = ( Item->Caption.Pos("<DIR>") != 0 )
? FILE_ATTRIBUTE_DIRECTORY
: FILE_ATTRIBUTE_NORMAL;
temp = Item->Caption;
p = temp.c_str();
}
else
{
PShellItem *pShellItem =
static_cast<PShellItem*>(pcList->Items[Item->Index]);
Attrs = pShellItem->Attributes;
Flags |= SHGFI_PIDL;
p = static_cast<char*>(pShellItem->FullID);
}
SHGetFileInfo(p, Attrs, &FileInfo, sizeof(FileInfo), Flags);
Item->ImageIndex = FileInfo.iIcon;
}
void __fastcall TMainForm::ListView_CustomDrawItem(TCustomListView
*Sender, TListItem* Item, TCustomDrawState State, bool &DefaultDraw)
{
TListView* lv = static_cast<TListView*>(Sender);
TFontStyles FontStyle = Sender->Canvas->Font->Style;
TColor FontColor;
int Attrs = ( lv == lvPC )
?
static_cast<PShellItem*>(pcList->Items[Item->Index])->Attributes
: 0;
if( Attrs & FILE_ATTRIBUTE_HIDDEN )
{
FontStyle << fsItalic;
FontColor = clGray;
}
else if( Attrs & FILE_ATTRIBUTE_SYSTEM )
{
FontStyle << fsItalic;
FontColor = clGradientInactiveCaption;
}
else
FontColor = Sender->Canvas->Font->Color;
lv->Canvas->Font->Style = FontStyle;
lv->Canvas->Font->Color = FontColor;
}
> A note about the "<DIR>" text: This is something FTP servers
> typically return
Not as typical as you think. There are literally dozens of completely
different, completely unrelated formats used for FTP directory listings.
This is because RFC 959 did not define a standard format for listings, so
most vendors choose to use thie own custom formats (a later draft proposal
added the MLSD command to the FTP protocol to address that, but the damnge
has already been done). If you look at the source code for Indy 10 sometime
(http://www.indyproject.org), you will see all of the various parser classes
that have to be used to handle all of these different vendor formats (and
more are added when they get discovered).
Gambit
Technical Details
Message-ID:
<4410cfe9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<440ef041$1@newsgroups.borland.com> <440f3555$3@newsgroups.borland.com> <44108aa0$1@newsgroups.borland.com> <441090a9$1@newsgroups.borland.com> <4410abd3@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9456c511753bafd3 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <440ef041$1@newsgroups.borland.com> <440f3555$3@newsgroups.borland.com> <44108aa0$1@newsgroups.borland.com> <441090a9$1@newsgroups.borland.com> <4410abd3@newsgroups.borland.com> Subject: Re: Getting SYS Icons Date: Thu, 9 Mar 2006 17:02:08 -0800 Lines: 95 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <4410cfe9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1141952489 68.69.17.41 (9 Mar 2006 17:01:29 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail