home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
-
- #include "UOwnerDraw.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- SHFILEINFO sfi;
-
- ListBox1->ItemHeight = GetSystemMetrics (SM_CYICON ) + 10;
- ImageList1->Handle = SHGetFileInfo ("", 0, &sfi, sizeof (sfi),
- SHGFI_SYSICONINDEX | SHGFI_LARGEICON);
- ImageList1->ShareImages = TRUE;
-
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ListBox1DrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State)
- {
- TRect r = Rect;
- // Clear the area to be drawn
- ListBox1->Canvas->FillRect (Rect);
- // Draw the icon
- ImageList1->Draw (ListBox1->Canvas, Rect.Left + 5, Rect.Top + 5, Index);
- // Now draw the text
- r.Left += GetSystemMetrics (SM_CXICON) + 10;
- DrawText (ListBox1->Canvas->Handle, ListBox1->Items->Strings [Index].c_str(), -1, (LPRECT) &r, DT_VCENTER | DT_SINGLELINE);
- }
- //---------------------------------------------------------------------------
-
-