aboutform.pas 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. unit aboutform;
  2. {*
  3. This source code is provided under the MIT license:
  4. Copyright (C) 2011 by Reinier Olislagers
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. *}
  21. {$mode objfpc}{$H+}
  22. interface
  23. uses
  24. Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
  25. type
  26. { TInfoAboutForm }
  27. TInfoAboutForm = class(TForm)
  28. CloseButton: TButton;
  29. InfoMemo: TMemo;
  30. procedure CloseButtonClick(Sender: TObject);
  31. procedure FormActivate(Sender: TObject);
  32. procedure FormCreate(Sender: TObject);
  33. private
  34. { private declarations }
  35. FFileName: string;
  36. FDoOnce: boolean;
  37. public
  38. { public declarations }
  39. property Filename: string read FFileName write FFileName;
  40. end;
  41. var
  42. InfoAboutForm: TInfoAboutForm;
  43. implementation
  44. uses
  45. CheckRideUtil;
  46. {$R *.lfm}
  47. { TInfoAboutForm }
  48. procedure TInfoAboutForm.CloseButtonClick(Sender: TObject);
  49. begin
  50. Close;
  51. end;
  52. procedure TInfoAboutForm.FormActivate(Sender: TObject);
  53. begin
  54. if FDoOnce then
  55. begin
  56. try
  57. InfoMemo.Lines.LoadFromFile(FFileName); //assumes file in same dir
  58. except
  59. try
  60. InfoMemo.Lines.LoadFromFile(FResourceDir + DirectorySeparator + FFileName);
  61. //Load from resource extract dir.
  62. except
  63. InfoMemo.Lines.Text := 'Sorry, could not load file ' + FFileName;
  64. end;
  65. end;
  66. FDoOnce := False;
  67. end;
  68. end;
  69. procedure TInfoAboutForm.FormCreate(Sender: TObject);
  70. begin
  71. if FFileName = '' then
  72. FFileName := 'readme.txt'; //Default
  73. FDoOnce := True;
  74. end;
  75. end.