🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4147

Re: Getting SYS Icons

#4147
From: poojo hackma
Date: Thu, 09 Mar 2006 22:27
48 lines
2997 bytes
Hello Hans,

All I used was the display name (no dir).  My code has 2 TListViews: one for 
files on the PC (lvPC), the other for files on the network (lvFtp).

My OnCustomDrawItem handler below is still messy, but it's working!  A note 
about the "<DIR>" text:  This is something FTP servers typically return, so 
I fill my TListItem->SubItems with this instead of leaving my Size field 
blank.
//-----------------------------------------------
void __fastcall TMainForm::ListView_CustomDrawItem(TCustomListView *Sender,
  TListItem* Item, TCustomDrawState State, bool &DefaultDraw) {
  TListView* lv = dynamic_cast<TListView*>(Sender);
  lv->Canvas->Font->Style = TFontStyles();
  lv->Canvas->Font->Color = clBlack;
  if (lv == lvFtp) {
    int Flags = SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON;
    TSHFileInfo FileInfo;
    memset(&FileInfo, 0, sizeof(FileInfo));
    char file[MAX_PATH + 1] = {0};
    strncpy(file, Item->Caption.c_str(), MAX_PATH); // Filename only. No 
directory
    if (strstr(Item->SubItems->GetText(), "<DIR>")) {
      SHGetFileInfo(file, FILE_ATTRIBUTE_DIRECTORY, &FileInfo, 
sizeof(FileInfo), Flags);
    } else {
      SHGetFileInfo(file, FILE_ATTRIBUTE_NORMAL, &FileInfo, 
sizeof(FileInfo), Flags);
    }
    Item->ImageIndex = FileInfo.iIcon;
  } else if (lv == lvPC) {
    int Attrs = ((PShellItem*)pcList->Items[Item->Index])->Attributes;
    if (BOOL(Attrs & FILE_ATTRIBUTE_HIDDEN)) {
      lv->Canvas->Font->Style = Sender->Canvas->Font->Style << fsItalic;
      lv->Canvas->Font->Color = clGray;
    }
    if (BOOL(Attrs & FILE_ATTRIBUTE_SYSTEM)) {
      lv->Canvas->Font->Style = Sender->Canvas->Font->Style << fsItalic;
      lv->Canvas->Font->Color = clGradientInactiveCaption;
    }
  }
}


> Can you please show how you construct the filename ? Is it something
> with the dir + DisplayName ?
>
> Hans. 
Technical Details
Message-ID: <4410abd3@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <440ef041$1@newsgroups.borland.com> <440f3555$3@newsgroups.borland.com> <44108aa0$1@newsgroups.borland.com> <441090a9$1@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: "poojo hackma" <poojo.com/mail>
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>
Subject: Re: Getting SYS Icons
Date: Thu, 9 Mar 2006 16:27:28 -0600
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
X-RFC2646: Format=Flowed; Response
X-Antivirus: avast! (VPS 0610-1, 03/08/2006), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: 12.45.133.147
Message-ID: <4410abd3@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1141943251 12.45.133.147 (9 Mar 2006 14:27:31 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail