source: cprs/branches/ScanSourceForConstants/ShowConstsU.pas@ 1582

Last change on this file since 1582 was 461, checked in by Kevin Toppenberg, 16 years ago

Initial upload of Multi-language support appt: ScanSourceForConstants

File size: 2.9 KB
RevLine 
[461]1unit ShowConstsU;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, Buttons, ExtCtrls;
8
9type
10 TConstantsOutputForm = class(TForm)
11 Panel1: TPanel;
12 ConstantsMemo: TMemo;
13 OpenButton: TBitBtn;
14 SaveButton: TBitBtn;
15 ClearButton: TBitBtn;
16 OKButton: TBitBtn;
17 OpenDialog1: TOpenDialog;
18 SaveDialog1: TSaveDialog;
19 SaveAsBitBtn: TBitBtn;
20 procedure OpenButtonClick(Sender: TObject);
21 procedure ClearButtonClick(Sender: TObject);
22 procedure SaveButtonClick(Sender: TObject);
23 procedure OKButtonClick(Sender: TObject);
24 procedure FormCreate(Sender: TObject);
25 procedure SaveAsBitBtnClick(Sender: TObject);
26 private
27 { Private declarations }
28 ConstantsText : AnsiString;
29 ConstantsFileName : string;
30 public
31 { Public declarations }
32 procedure AddConst(constSName,constStr : string);
33 function NeedsSave: boolean;
34 end;
35
36var
37 ConstantsOutputForm: TConstantsOutputForm;
38
39implementation
40
41{$R *.dfm}
42
43procedure TConstantsOutputForm.OpenButtonClick(Sender: TObject);
44begin
45 //CHANGE--first ask user "SURE?"
46 if OpenDialog1.Execute then begin
47 ConstantsFileName := OpenDialog1.FileName;
48 ConstantsMemo.Lines.LoadFromFile(ConstantsFileName);
49 end;
50end;
51
52procedure TConstantsOutputForm.ClearButtonClick(Sender: TObject);
53var choice : integer;
54begin
55 choice := mrYes;
56 if NeedsSave then choice := MessageDlg('Clear Current Constants? (This can not be undone.)',
57 mtConfirmation, [mbYes,mbNo,mbCancel], 0);
58 if choice=mrYes then ConstantsMemo.Lines.Clear;
59end;
60
61procedure TConstantsOutputForm.SaveButtonClick(Sender: TObject);
62begin
63 if ConstantsFileName <> '' then ConstantsMemo.Lines.SaveToFile(ConstantsFileName);
64 ConstantsText:=ConstantsMemo.Text; // tracks if save needed.
65end;
66
67procedure TConstantsOutputForm.SaveAsBitBtnClick(Sender: TObject);
68begin
69 if SaveDialog1.Execute then begin
70 ConstantsFileName := SaveDialog1.FileName;
71 ConstantsMemo.Lines.SaveToFile(ConstantsFileName);
72 ConstantsText:=ConstantsMemo.Text; // tracks if save needed.
73 end;
74end;
75
76procedure TConstantsOutputForm.OKButtonClick(Sender: TObject);
77begin
78 ConstantsOutputForm.Hide;
79end;
80
81
82procedure TConstantsOutputForm.AddConst(constSName,constStr : string);
83var tempS : string;
84begin
85 tempS := constSName+'='+constStr;
86 if ConstantsMemo.Lines.IndexOf(tempS)<0 then begin
87 ConstantsMemo.Lines.Add(tempS);
88 end;
89end;
90
91function TConstantsOutputForm.NeedsSave: boolean;
92begin
93 Result := ConstantsMemo.Modified;
94 //Result := (ConstantsText=ConstantsMemo.Text);
95end;
96
97
98procedure TConstantsOutputForm.FormCreate(Sender: TObject);
99var choice: integer;
100begin
101 choice := MessageDlg('Open Existing Constants File?', mtCustom, [mbYes,mbNo], 0);
102 if choice=mrYes then OpenButtonClick(Sender);
103end;
104
105
106end.
Note: See TracBrowser for help on using the repository browser.