void __fastcall TForm1::ListBox1MeasureItem(TWinControl
*Control,
int Index, int &Height)
{
ListBox1->Canvas->Font->Name = ListBox1->Items->Strings[Index];
ListBox1->Canvas->Font->Size = 0; // use font's preferred
size
Height = ListBox1->Canvas->TextHeight("Wg") + 2;
// measure ascenders and //descenders
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
FontLabel->Caption = ListBox1->Items->Strings[ListBox1->ItemIndex];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1DrawItem(TWinControl *Control,
int Index,
TRect &Rect, TOwnerDrawState State)
{
ListBox1->Canvas->FillRect(Rect);
ListBox1->Canvas->Font->Name = ListBox1->Items->Strings[Index];
ListBox1->Canvas->Font->Size = 0; // use font's preferred
size
ListBox1->Canvas->TextOut(Rect.Left+1, Rect.Top+1, ListBox1->Items->Strings[Index]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ListBox1->Items = Screen->Fonts;
}
//---------------------------------------------------------------------------
|