1 |
(*
|
2 |
* AddSecondaryFileDlgUnit.pas
|
3 |
* Copyright (C) 2018 Tony Whyman <tony@mwasoftware.co.uk>
|
4 |
*
|
5 |
* DBAdmin is free software: you can redistribute it and/or modify it
|
6 |
* under the terms of the GNU General Public License as published by the
|
7 |
* Free Software Foundation, either version 3 of the License, or
|
8 |
* (at your option) any later version.
|
9 |
*
|
10 |
* DBAdmin is distributed in the hope that it will be useful, but
|
11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
13 |
* See the GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License along
|
16 |
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 |
*)
|
18 |
unit AddSecondaryFileDlgUnit;
|
19 |
|
20 |
{$mode objfpc}{$H+}
|
21 |
|
22 |
interface
|
23 |
|
24 |
uses
|
25 |
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
26 |
StdCtrls;
|
27 |
|
28 |
type
|
29 |
|
30 |
{ TAddSecondaryFileDlg }
|
31 |
|
32 |
TAddSecondaryFileDlg = class(TForm)
|
33 |
Bevel1: TBevel;
|
34 |
Button1: TButton;
|
35 |
Button2: TButton;
|
36 |
FileLength: TEdit;
|
37 |
FileName: TEdit;
|
38 |
InPagesBtn: TRadioButton;
|
39 |
Label1: TLabel;
|
40 |
Label2: TLabel;
|
41 |
Label3: TLabel;
|
42 |
RadioButton2: TRadioButton;
|
43 |
StartAfter: TEdit;
|
44 |
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
45 |
private
|
46 |
|
47 |
public
|
48 |
function ShowModal(var aFileName: string; var aStartAfter, aFileLength: integer;
|
49 |
var aPages: boolean): TModalResult;
|
50 |
end;
|
51 |
|
52 |
var
|
53 |
AddSecondaryFileDlg: TAddSecondaryFileDlg;
|
54 |
|
55 |
implementation
|
56 |
|
57 |
{$R *.lfm}
|
58 |
|
59 |
{ TAddSecondaryFileDlg }
|
60 |
|
61 |
procedure TAddSecondaryFileDlg.FormClose(Sender: TObject;
|
62 |
var CloseAction: TCloseAction);
|
63 |
var i: integer;
|
64 |
begin
|
65 |
if ModalResult = mrOK then
|
66 |
begin
|
67 |
if not TryStrToInt(StartAfter.Text,i) then
|
68 |
begin
|
69 |
MessageDlg('Start After must be an integer',mtError,[mbOK],0);
|
70 |
StartAfter.SetFocus;
|
71 |
CloseAction := caNone;
|
72 |
Exit;
|
73 |
end;
|
74 |
if (FileLength.Text <> '') and not TryStrToInt(FileLength.Text,i) then
|
75 |
begin
|
76 |
MessageDlg('File Length must be an integer or empty',mtError,[mbOK],0);
|
77 |
FileLength.SetFocus;
|
78 |
CloseAction := caNone;
|
79 |
Exit;
|
80 |
end;
|
81 |
if FileName.Text = '' then
|
82 |
begin
|
83 |
MessageDlg('A File name must be given',mtError,[mbOK],0);
|
84 |
FileName.SetFocus;
|
85 |
CloseAction := caNone;
|
86 |
Exit;
|
87 |
end;
|
88 |
end;
|
89 |
end;
|
90 |
|
91 |
function TAddSecondaryFileDlg.ShowModal(var aFileName: string; var aStartAfter,
|
92 |
aFileLength: integer; var aPages: boolean): TModalResult;
|
93 |
begin
|
94 |
StartAfter.Text := IntToStr(aStartAfter);
|
95 |
FileName.Text := '';
|
96 |
FileLength.Text := '';
|
97 |
Result := inherited ShowModal;
|
98 |
if Result = mrOK then
|
99 |
begin
|
100 |
aFileName := FileName.Text;
|
101 |
aStartAfter := StrToInt(StartAfter.Text);
|
102 |
aPages := InPagesBtn.Checked;
|
103 |
if FileLength.Text <> '' then
|
104 |
aFileLength := StrToInt(FileLength.Text)
|
105 |
else
|
106 |
aFileLength := -1;
|
107 |
end;
|
108 |
end;
|
109 |
|
110 |
end.
|
111 |
|