home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / borland / cb / setup / cbuilder / data.z / FONTLIST.CPP < prev    next >
C/C++ Source or Header  |  1997-02-28  |  2KB  |  42 lines

  1. //----------------------------------------------------------------------------
  2. //Borland C++Builder
  3. //Copyright (c) 1987, 1997 Borland International Inc. All Rights Reserved.
  4. //----------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include "FontList.h"
  7. //---------------------------------------------------------------------------
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.   : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::FormCreate(TObject *Sender)
  17. {
  18.   ListBox1->Items = Screen->Fonts;
  19. }
  20. //---------------------------------------------------------------------
  21. void __fastcall TForm1::ListBox1Click(TObject *Sender)
  22. {
  23.     FontLabel->Caption =  ListBox1->Items->Strings[ListBox1->ItemIndex].c_str();
  24. }
  25. //---------------------------------------------------------------------
  26. void __fastcall TForm1::DrawItem(TWinControl *Control,
  27.       int Index, TRect &Rect, TOwnerDrawState State)
  28. {
  29.     ListBox1->Canvas->FillRect(Rect);
  30.     ListBox1->Canvas->Font->Name =ListBox1->Items->Strings[Index].c_str();
  31.     ListBox1->Canvas->Font->Size = 0;
  32.     ListBox1->Canvas->TextOut(Rect.Left+1, Rect.Top+1, ListBox1->Items->Strings[Index].c_str());
  33. }
  34. //---------------------------------------------------------------------
  35. void __fastcall TForm1::ListBox1MeasureItem(TWinControl *Control,
  36.       int Index, int &Height)
  37. {
  38.    ListBox1->Canvas->Font->Name =ListBox1->Items->Strings[Index].c_str();
  39.    ListBox1->Canvas->Font->Size = 0;
  40.    Height = ListBox1->Canvas->TextHeight("Wg") +2;
  41. }
  42. //---------------------------------------------------------------------