-
Notifications
You must be signed in to change notification settings - Fork 4
/
udCreateAlias.pas
85 lines (75 loc) · 2.09 KB
/
udCreateAlias.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
unit udCreateAlias;
{
July 2015 Code By: Daniel Campbell
}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, JvExMask, JvToolEdit;
type
TdCreateAlias = class(TForm)
Label1: TLabel;
edtAlias: TEdit;
lblAlias: TLabel;
btnCancel: TButton;
btnOK: TButton;
edtWorkingDirectory: TJvDirectoryEdit;
procedure btnOKClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
fAliasFixed : Boolean;
public
{ Public declarations }
procedure SetUp(aAlias : String; aWorkingDirectory : String; aAliasFixed : Boolean);
procedure GetAlias(var aAlias, aWorkingDirectory: String);
end;
implementation
procedure TdCreateAlias.SetUp(aAlias : String; aWorkingDirectory : String;
aAliasFixed : Boolean);
begin
edtAlias.Text := aAlias;
edtWorkingDirectory.Text := aWorkingDirectory;
fAliasFixed := aAliasFixed;
end;
procedure TdCreateAlias.FormShow(Sender: TObject);
begin
if fAliasFixed then
begin
edtWorkingDirectory.SetFocus;
edtAlias.Enabled := False;
btnOK.Caption := 'Edit';
Self.Caption := 'Set Working Directory';
end
else
begin
edtAlias.SetFocus;
btnOK.Caption := 'Create';
Self.Caption := 'Create Alias';
end;
end;
procedure TdCreateAlias.btnOKClick(Sender: TObject);
begin
if not DirectoryExists(edtWorkingDirectory.Text) then
begin
ShowMessage('Working Directory does not exist');
edtWorkingDirectory.SetFocus;
ModalResult := mrNone;
end
else
ModalResult := mrOk;
end;
procedure TdCreateAlias.GetAlias(var aAlias : String; var aWorkingDirectory : String);
begin
aAlias := edtAlias.Text;
aWorkingDirectory := edtWorkingDirectory.Text;
end;
procedure TdCreateAlias.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
Close;
end;
{$R *.dfm}
end.