home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / LISTFONT / MAIN.PAS < prev   
Pascal/Delphi Source File  |  1998-04-13  |  2KB  |  73 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Spin, Buttons, ExtCtrls;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     FontListBox: TListBox;
  12.     Label1: TLabel;
  13.     SampleLabel: TLabel;
  14.     SpinEdit1: TSpinEdit;
  15.     Label3: TLabel;
  16.     FontNameLabel: TLabel;
  17.     Label2: TLabel;
  18.     Bevel1: TBevel;
  19.     CloseBitBtn: TBitBtn;
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure FontListBoxDblClick(Sender: TObject);
  22.     procedure FontListBoxKeyDown(Sender: TObject; var Key: Word;
  23.       Shift: TShiftState);
  24.     procedure SpinEdit1Change(Sender: TObject);
  25.     procedure CloseBitBtnClick(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   MainForm: TMainForm;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure TMainForm.FormCreate(Sender: TObject);
  40. begin
  41.   FontListBox.Items := Screen.Fonts;
  42. end;
  43.  
  44. procedure TMainForm.FontListBoxDblClick(Sender: TObject);
  45. begin
  46.   with FontListBox do
  47.   if ItemIndex >= 0 then
  48.   begin
  49.     SampleLabel.Font.Name := FontListBox.Items[ItemIndex];
  50.     FontNameLabel.Caption := SampleLabel.Font.Name;
  51.   end;
  52. end;
  53.  
  54. procedure TMainForm.FontListBoxKeyDown(Sender: TObject; var Key: Word;
  55.   Shift: TShiftState);
  56. begin
  57.   if Key in [VK_RETURN, VK_SPACE] then
  58.     FontListBoxDblClick(Sender);
  59. end;
  60.  
  61. procedure TMainForm.SpinEdit1Change(Sender: TObject);
  62. begin
  63.   SampleLabel.Font.Size := SpinEdit1.Value;
  64. end;
  65.  
  66. procedure TMainForm.CloseBitBtnClick(Sender: TObject);
  67. begin
  68.   Close;
  69. end;
  70.  
  71. end.
  72.  
  73.