home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk15 / ownerlst.pak / FONTLIST.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1995-08-24  |  1.4 KB  |  63 lines

  1. unit Fontlist;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls;
  6.  
  7. type
  8.   TForm1 = class(TForm)
  9.     ListBox1: TListBox;
  10.     Label1: TLabel;
  11.     FontLabel: TLabel;
  12.     procedure FormCreate(Sender: TObject);
  13.     procedure ListBox1Click(Sender: TObject);
  14.     procedure DrawItem(Control: TWinControl; Index: Integer; Rect: TRect;
  15.       State: TOwnerDrawState);
  16.     procedure ListBox1MeasureItem(Control: TWinControl; Index: Integer;
  17.       var Height: Integer);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.DFM}
  30.  
  31. procedure TForm1.FormCreate(Sender: TObject);
  32. begin
  33.   Listbox1.Items := Screen.Fonts;
  34. end;
  35.  
  36. procedure TForm1.ListBox1Click(Sender: TObject);
  37. begin
  38.   FontLabel.Caption := ListBox1.Items[ListBox1.ItemIndex];
  39. end;
  40.  
  41. procedure TForm1.DrawItem(Control: TWinControl; Index: Integer;
  42.   Rect: TRect; State: TOwnerDrawState);
  43. begin
  44.   with ListBox1.Canvas do
  45.   begin
  46.     FillRect(Rect);
  47.     Font.Name := ListBox1.Items[Index];
  48.     TextOut(Rect.Left, Rect.Top, ListBox1.Items[Index]);
  49.   end;
  50. end;
  51.  
  52. procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
  53.   var Height: Integer);
  54. begin
  55.   with ListBox1.Canvas do
  56.   begin
  57.     Font.Name := ListBox1.Items[Index];
  58.     Height := TextHeight('A');
  59.   end;
  60. end;
  61.  
  62. end.
  63.