String_frMain.pas 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. (* _ _
  2. * | |__ _ __ ___ ___ | | __
  3. * | '_ \| '__/ _ \ / _ \| |/ /
  4. * | |_) | | | (_) | (_) | <
  5. * |_.__/|_| \___/ \___/|_|\_\
  6. *
  7. * Microframework which helps to develop web Pascal applications.
  8. *
  9. * Copyright (c) 2012-2020 Silvio Clecio <[email protected]>
  10. *
  11. * Brook framework is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 2.1 of the License, or (at your option) any later version.
  15. *
  16. * Brook framework is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with Brook framework; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *)
  25. { This example show a basic usage of TBrookString. }
  26. unit String_frMain;
  27. {$MODE DELPHI}
  28. interface
  29. uses
  30. SysUtils,
  31. StdCtrls,
  32. Forms,
  33. Dialogs,
  34. BrookString;
  35. type
  36. TfrMain = class(TForm)
  37. btAddNow: TButton;
  38. btShowContent: TButton;
  39. btClear: TButton;
  40. lbDesc: TLabel;
  41. procedure btAddNowClick(Sender: TObject);
  42. procedure btClearClick(Sender: TObject);
  43. procedure btShowContentClick(Sender: TObject);
  44. procedure FormCreate(Sender: TObject);
  45. procedure FormDestroy(Sender: TObject);
  46. private
  47. FString: TBrookString;
  48. protected
  49. procedure UpdateButtons;
  50. end;
  51. var
  52. frMain: TfrMain;
  53. implementation
  54. {$R *.lfm}
  55. procedure TfrMain.FormCreate(Sender: TObject);
  56. begin
  57. FString := TBrookString.Create(nil);
  58. end;
  59. procedure TfrMain.FormDestroy(Sender: TObject);
  60. begin
  61. FString.Free;
  62. end;
  63. procedure TfrMain.UpdateButtons;
  64. begin
  65. btShowContent.Enabled := FString.Length > 0;
  66. btClear.Enabled := btShowContent.Enabled;
  67. end;
  68. procedure TfrMain.btAddNowClick(Sender: TObject);
  69. begin
  70. FString.Write(Format('%s%s', [FormatDateTime('hh:nn:ss.zzz', Now), sLineBreak]));
  71. UpdateButtons;
  72. end;
  73. procedure TfrMain.btShowContentClick(Sender: TObject);
  74. begin
  75. ShowMessageFmt('All clicks:%s%s%s', [sLineBreak, sLineBreak, FString.Text]);
  76. end;
  77. procedure TfrMain.btClearClick(Sender: TObject);
  78. begin
  79. FString.Clear;
  80. UpdateButtons;
  81. end;
  82. end.