1 |
tony |
158 |
(*
|
2 |
|
|
* AddShadowFileDlgUnit.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 AddShadowFileDlgUnit;
|
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 |
|
|
{ TAddShadowFileDlg }
|
31 |
|
|
|
32 |
|
|
TAddShadowFileDlg = class(TForm)
|
33 |
|
|
Bevel1: TBevel;
|
34 |
|
|
Button1: TButton;
|
35 |
|
|
Button2: TButton;
|
36 |
|
|
FileLength: TEdit;
|
37 |
|
|
FileName: TEdit;
|
38 |
|
|
InPagesBtn: TRadioButton;
|
39 |
|
|
Label1: TLabel;
|
40 |
|
|
Label3: TLabel;
|
41 |
|
|
RadioButton2: TRadioButton;
|
42 |
|
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
43 |
|
|
procedure FormShow(Sender: TObject);
|
44 |
|
|
private
|
45 |
|
|
|
46 |
|
|
public
|
47 |
|
|
function ShowModal(var aFileName: string; var aFileLength: integer;
|
48 |
|
|
var aPages: boolean): TModalResult;
|
49 |
|
|
end;
|
50 |
|
|
|
51 |
|
|
var
|
52 |
|
|
AddShadowFileDlg: TAddShadowFileDlg;
|
53 |
|
|
|
54 |
|
|
implementation
|
55 |
|
|
|
56 |
|
|
{$R *.lfm}
|
57 |
|
|
|
58 |
|
|
{ TAddShadowFileDlg }
|
59 |
|
|
|
60 |
|
|
procedure TAddShadowFileDlg.FormClose(Sender: TObject;
|
61 |
|
|
var CloseAction: TCloseAction);
|
62 |
|
|
var i: integer;
|
63 |
|
|
begin
|
64 |
|
|
if ModalResult = mrOK then
|
65 |
|
|
begin
|
66 |
|
|
if (FileLength.Text <> '') and not TryStrToInt(FileLength.Text,i) then
|
67 |
|
|
begin
|
68 |
|
|
MessageDlg('File Length must be an integer or empty',mtError,[mbOK],0);
|
69 |
|
|
FileLength.SetFocus;
|
70 |
|
|
CloseAction := caNone;
|
71 |
|
|
Exit;
|
72 |
|
|
end;
|
73 |
|
|
if FileName.Text = '' then
|
74 |
|
|
begin
|
75 |
|
|
MessageDlg('A File name must be given',mtError,[mbOK],0);
|
76 |
|
|
FileName.SetFocus;
|
77 |
|
|
CloseAction := caNone;
|
78 |
|
|
Exit;
|
79 |
|
|
end;
|
80 |
|
|
end;
|
81 |
|
|
end;
|
82 |
|
|
|
83 |
|
|
procedure TAddShadowFileDlg.FormShow(Sender: TObject);
|
84 |
|
|
begin
|
85 |
|
|
FileName.SetFocus;
|
86 |
|
|
end;
|
87 |
|
|
|
88 |
|
|
function TAddShadowFileDlg.ShowModal(var aFileName: string;
|
89 |
|
|
var aFileLength: integer; var aPages: boolean): TModalResult;
|
90 |
|
|
begin
|
91 |
|
|
FileName.Text := '';
|
92 |
|
|
FileLength.Text := '';
|
93 |
|
|
Result := inherited ShowModal;
|
94 |
|
|
if Result = mrOK then
|
95 |
|
|
begin
|
96 |
|
|
aFileName := FileName.Text;
|
97 |
|
|
aPages := InPagesBtn.Checked;
|
98 |
|
|
if FileLength.Text <> '' then
|
99 |
|
|
aFileLength := StrToInt(FileLength.Text)
|
100 |
|
|
else
|
101 |
|
|
aFileLength := -1;
|
102 |
|
|
end;
|
103 |
|
|
end;
|
104 |
|
|
|
105 |
|
|
end.
|
106 |
|
|
|