-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmEditors.pas
110 lines (95 loc) · 2.7 KB
/
frmEditors.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
unit frmEditors;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, ShellApi,
Vcl.Mask;
type
TwndEditors = class(TForm)
edName: TLabeledEdit;
edPath: TLabeledEdit;
edParam: TLabeledEdit;
btnFindExecutable: TButton;
odEditor: TOpenDialog;
btnAdd: TButton;
btnCancel: TButton;
edImage: TImage;
egParams: TEdit;
procedure btnAddClick(Sender: TObject);
procedure btnFindExecutableClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure edPathChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
wndEditors: TwndEditors;
implementation
uses main, settings, functions;
{$R *.dfm}
procedure TwndEditors.btnAddClick(Sender: TObject);
//var
//ed: PSTextEditor;
begin
main.Settings.CodeEditors.Append(TCodeEditor.Create(edName.Text, edPath.Text, edParam.Text));
{GetMem(ed, SizeOf(TSTextEditor));
ed^.Name := edName.Text;
ed^.Path := edPath.Text;
ed^.Param := edParam.Text;
ed^.Enabled := True;
main.Settings.TextEditors.Add(ed);}
Close;
end;
procedure TwndEditors.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TwndEditors.btnFindExecutableClick(Sender: TObject);
var
exeInfo: TExeInfo;
Icon: TIcon;
begin
with odEditor do
begin
Filter := 'Executables|*.exe|All files|*.*';
Title := 'Select your text editor executable';
if Execute then
begin
edPath.Text := FileName;
exeInfo := GetExeInfo(FileName);
if exeInfo.ProductName <> '' then
edName.Text := exeInfo.ProductName
else
begin
edName.Text := ExtractFileName(FileName);
edName.Text := ChangeFileExt(edName.Text, '');
end;
Icon := TIcon.Create;
try
Icon.Transparent := True;
Icon.Handle := ExtractIcon(HInstance, PChar(FileName), Word(0));
edImage.Picture.Assign(Icon);
finally
Icon.Free;
end;
egParams.Text := '...\'+ExtractFileName(FileName) + ' ' + edParam.Text;
end;
end;
end;
procedure TwndEditors.edPathChange(Sender: TObject);
begin
egParams.Text := '...\'+ExtractFileName(odEditor.FileName) + ' ' + edParam.Text;
end;
procedure TwndEditors.FormClose(Sender: TObject; var Action: TCloseAction);
begin
NotModal := True;
end;
procedure TwndEditors.FormCreate(Sender: TObject);
begin
EnableImmersiveDarkMode(True);
end;
end.