unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
LCLType;
type
{ TForm1 }
TForm1 = class(TForm)
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
Edit2: TEdit;
Memo1: TMemo;
Memo2: TMemo;
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Items.Add('Orange');
ComboBox1.Items.Add('Banana');
ComboBox1.Items.Add('Grape');
ComboBox2.Items.Add('Coffee');
ComboBox2.Items.Add('Tea');
ComboBox2.Items.Add('Juice');
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
const
OutputFileName = 'report.txt';
var
OutputFile: TStringList;
begin
if (Application.MessageBox('Save report to ' + OutputFileName + '?',
'Save Report', MB_YESNO) <> IDYES) then
Exit;
OutputFile := TStringList.Create;
// Save ComboBox data
OutputFile.Add('// ComboBox1');
OutputFile.Add(ComboBox1.Text);
OutputFile.Add('');
OutputFile.Add('// ComboBox');
OutputFile.Add(ComboBox2.Text);
OutputFile.Add('');
// Save Edit data
OutputFile.Add('//Edit1');
OutputFile.Add(Edit1.Text);
OutputFile.Add('');
OutputFile.Add('//Edit2');
OutputFile.Add(Edit2.Text);
OutputFile.Add('');
// Save Memo data
OutputFile.Add('// ---- start of Memo1 ----');
OutputFile.AddStrings(Memo1.Lines);
OutputFile.Add('// --- end of Memo1 ---');
OutputFile.Add('');
OutputFile.Add('// --- start of Memo2 ---');
OutputFile.AddStrings(Memo2.Lines);
OutputFile.Add('// --- end of Memo2 ---');
OutputFile.Add('');
// Save CheckBox data
OutputFile.Add('Checkbox1 = ' + CheckBox1.Checked.ToString);
OutputFile.Add('Checkbox2 = ' + CheckBox2.Checked.ToString);
OutputFile.Add('Checkbox3 = ' + CheckBox3.Checked.ToString);
OutputFile.Add('Checkbox4 = ' + CheckBox4.Checked.ToString);
OutputFile.SaveToFile(OutputFileName);
end;
end.