StyleSelectionUnit.pas 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. unit StyleSelectionUnit;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5. StdCtrls, ExtCtrls;
  6. type
  7. TStyleSelectionForm = class(TForm)
  8. CheckBox1: TCheckBox;
  9. CheckBox2: TCheckBox;
  10. CheckBox3: TCheckBox;
  11. CheckBox4: TCheckBox;
  12. CheckBox5: TCheckBox;
  13. Bevel1: TBevel;
  14. Button1: TButton;
  15. Button2: TButton;
  16. procedure CheckBox1Click(Sender: TObject);
  17. procedure FormShow(Sender: TObject);
  18. procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19. private
  20. public
  21. Style: TFontStyles;
  22. CustomStyle: Boolean;
  23. end;
  24. implementation
  25. {$R *.DFM}
  26. procedure TStyleSelectionForm.CheckBox1Click(Sender: TObject);
  27. begin
  28. CheckBox2.Enabled := CheckBox1.Checked;
  29. CheckBox3.Enabled := CheckBox1.Checked;
  30. CheckBox4.Enabled := CheckBox1.Checked;
  31. CheckBox5.Enabled := CheckBox1.Checked;
  32. if not CheckBox2.Enabled then
  33. CheckBox2.Checked := False;
  34. if not CheckBox3.Enabled then
  35. CheckBox3.Checked := False;
  36. if not CheckBox4.Enabled then
  37. CheckBox4.Checked := False;
  38. if not CheckBox5.Enabled then
  39. CheckBox5.Checked := False;
  40. end;
  41. procedure TStyleSelectionForm.FormShow(Sender: TObject);
  42. begin
  43. CheckBox1.Checked := CustomStyle;
  44. CheckBox2.Checked := fsBold in Style;
  45. CheckBox3.Checked := fsItalic in Style;
  46. CheckBox4.Checked := fsUnderline in Style;
  47. CheckBox5.Checked := fsStrikeOut in Style;
  48. CheckBox1Click (Sender);
  49. end;
  50. procedure TStyleSelectionForm.FormClose(Sender: TObject;
  51. var Action: TCloseAction);
  52. begin
  53. CustomStyle := CheckBox1.Checked;
  54. if CustomStyle then begin
  55. Style := [];
  56. if CheckBox2.Checked then
  57. Include (Style, fsBold);
  58. if CheckBox3.Checked then
  59. Include (Style, fsItalic);
  60. if CheckBox4.Checked then
  61. Include (Style, fsUnderline);
  62. if CheckBox5.Checked then
  63. Include (Style, fsStrikeOut);
  64. end;
  65. end;
  66. end.