home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0003_Control Font Styles.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-22  |  834 b   |  36 lines

  1.  
  2. Control Font Styles:
  3.  
  4. This code will change the font style of a Edit
  5. when selected. This code could be implemented to
  6. control font style on other objects.
  7.  
  8. With a Edit(Edit1) and a ListBox(ListBox1) on a form
  9. Add the following Items to the ListBox:
  10.    fsBold
  11.    fsItalic
  12.    fsUnderLine
  13.    fsStrikeOut
  14.  
  15. procedure TForm1.ListBox1Click(Sender: TObject);
  16. var
  17.   X : Integer;
  18. type
  19.   TLookUpRec = record
  20.     Name: String;
  21.     Data: TFontStyle;
  22.   end;
  23. const
  24.   LookUpTable: array[1..4] of TLookUpRec =
  25.  
  26.   ((Name: 'fsBold'; Data: fsBold),
  27.    (Name: 'fsItalic'; Data: fsItalic),
  28.    (Name: 'fsUnderline'; Data: fsUnderline),
  29.    (Name: 'fsStrikeOut'; Data: fsStrikeOut));
  30. begin
  31.   X := ListBox1.ItemIndex;
  32.   Edit1.Text := ListBox1.Items[X];
  33.   Edit1.Font.Style := [LookUpTable[ListBox1.ItemIndex+1].Data];
  34. end;
  35.  
  36.