FreeLaunch

Форк
0
/
FilePropertiesFormModule.pas 
218 строк · 7.6 Кб
1
{
2
  ##########################################################################
3
  #  FreeLaunch is a free links manager for Microsoft Windows              #
4
  #                                                                        #
5
  #  Copyright (C) 2023 Alexey Tatuyko <feedback@ta2i4.ru>                 #
6
  #  Copyright (C) 2019 Mykola Petrivskiy                                  #
7
  #  Copyright (C) 2010 Joker-jar <joker-jar@yandex.ru>                    #
8
  #                                                                        #
9
  #  This file is part of FreeLaunch.                                      #
10
  #                                                                        #
11
  #  FreeLaunch is free software: you can redistribute it and/or modify    #
12
  #  it under the terms of the GNU General Public License as published by  #
13
  #  the Free Software Foundation, either version 3 of the License, or     #
14
  #  (at your option) any later version.                                   #
15
  #                                                                        #
16
  #  FreeLaunch is distributed in the hope that it will be useful,         #
17
  #  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
18
  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
19
  #  GNU General Public License for more details.                          #
20
  #                                                                        #
21
  #  You should have received a copy of the GNU General Public License     #
22
  #  along with FreeLaunch. If not, see <http://www.gnu.org/licenses/>.    #
23
  ##########################################################################
24
}
25

26
unit FilePropertiesFormModule;
27

28
interface
29

30
uses
31
  Winapi.Windows, Winapi.Messages, Winapi.ShellAPI,
32
  System.SysUtils, System.Variants, System.Classes, System.IniFiles,
33
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls,
34
  Vcl.ExtCtrls, Vcl.StdCtrls,
35
  ChangeIconFormModule, FLData, FLFunctions, FLLanguage;
36

37
type
38
  TFilePropertiesForm = class(TForm)
39
    PageControl1: TPageControl;
40
    TabSheet1: TTabSheet;
41
    Label1: TLabel;
42
    Label4: TLabel;
43
    DescrEdit: TEdit;
44
    Label7: TLabel;
45
    WStyleBox: TComboBox;
46
    Bevel1: TBevel;
47
    Label5: TLabel;
48
    Bevel2: TBevel;
49
    Bevel3: TBevel;
50
    Label6: TLabel;
51
    IcImage: TImage;
52
    ChangeIconButton: TButton;
53
    QuesCheckBox: TCheckBox;
54
    OKButton: TButton;
55
    CancelButton: TButton;
56
    HideCheckBox: TCheckBox;
57
    Label9: TLabel;
58
    CommandEdit: TButtonedEdit;
59
    RefProps: TButton;
60
    WorkFolderEdit: TButtonedEdit;
61
    procedure FormShow(Sender: TObject);
62
    procedure BrowseExecClick(Sender: TObject);
63
    procedure OKButtonClick(Sender: TObject);
64
    procedure ChangeIconButtonClick(Sender: TObject);
65
    procedure RefPropsClick(Sender: TObject);
66
    procedure CommandEditChange(Sender: TObject);
67
    procedure WorkFolderClick(Sender: TObject);
68
  private
69
    Link: TLink;
70
  public
71
    procedure RefreshProps;
72
    class function Execute(ALink: TLink): TLink;
73
  end;
74

75
var
76
  ic: string;
77
  iconindex: integer;
78

79
implementation
80

81
uses
82
  FLaunchMainFormModule, FLDialogs;
83

84
{$R *.dfm}
85

86
procedure TFilePropertiesForm.ChangeIconButtonClick(Sender: TObject);
87
var
88
  frm: TChangeIconForm;
89
begin
90
  Application.CreateForm(TChangeIconForm, frm);
91
  frm.ShowModal;
92
  FlaunchMainForm.LoadIcFromFileNoModif(IcImage, GetAbsolutePath(ic), iconindex);
93
end;
94

95
procedure TFilePropertiesForm.CommandEditChange(Sender: TObject);
96
begin
97
  OKButton.Enabled := FileExists(GetAbsolutePath(CommandEdit.Text)) or DirectoryExists(GetAbsolutePath(CommandEdit.Text));
98
end;
99

100
class function TFilePropertiesForm.Execute(ALink: TLink): TLink;
101
begin
102
  with TFilePropertiesForm.Create(Application.MainForm) do
103
  try
104
    Link := ALink;
105
    ShowModal;
106
  finally
107
    Result := Link;
108
    Free;
109
  end;
110
end;
111

112
procedure TFilePropertiesForm.OKButtonClick(Sender: TObject);
113
begin
114
  if (not FileExists(GetAbsolutePath(CommandEdit.Text))) and (not DirectoryExists(GetAbsolutePath(CommandEdit.Text))) then
115
    begin
116
      fillchar(Link, sizeof(TLink), 0);
117
      exit;
118
    end;
119
  Link.active := true;
120
  Link.ltype := 1;
121
  Link.exec := CommandEdit.Text;
122
  Link.workdir := WorkFolderEdit.Text;
123
  Link.descr := DescrEdit.Text;
124
  Link.icon := ic;
125
  Link.iconindex := iconindex;
126
  Link.ques := QuesCheckBox.Checked;
127
  Link.hide := HideCheckBox.Checked;
128
  Link.wst := WStyleBox.ItemIndex;
129
end;
130

131
procedure TFilePropertiesForm.RefPropsClick(Sender: TObject);
132
begin
133
  RefreshProps;
134
end;
135

136
procedure TFilePropertiesForm.FormShow(Sender: TObject);
137
begin
138
  if AlwaysOnTop then FormStyle := fsStayOnTop;
139
  //--Loading language
140
  OKButton.Caption := Language.BtnOk;
141
  CancelButton.Caption := Language.BtnCancel;
142
  PageControl1.Pages[0].Caption := Language.Properties.Caption;
143
  Caption := Language.Properties.Caption;
144
  Label9.Caption := Language.Properties.Folder + ':';
145
  Label1.Caption := Language.Properties.LblObject + ':';
146
  Label4.Caption := Language.Properties.Description + ':';
147
  Label7.Caption := Language.Properties.View + ':';
148
  WStyleBox.Items.Add(Language.Properties.ViewNormal);
149
  WStyleBox.Items.Add(Language.Properties.ViewMax);
150
  WStyleBox.Items.Add(Language.Properties.ViewMin);
151
  WStyleBox.Items.Add(Language.Properties.ViewHidden);
152
  CommandEdit.RightButton.Hint := Language.Properties.BeHint;
153
  RefProps.Hint := Language.Properties.RpHint;
154
  Label5.Caption := Language.Properties.Options;
155
  Bevel2.Left := Label5.Left + Label5.Width + 7;
156
  Bevel2.Width := TabSheet1.Width - Bevel2.Left - 7;
157
  Label6.Caption := Language.Properties.Icon;
158
  Bevel3.Left := Label6.Left + Label6.Width + 7;
159
  Bevel3.Width := TabSheet1.Width - Bevel3.Left - 7;
160
  ChangeIconButton.Caption := Language.Properties.Change;
161
  QuesCheckBox.Caption := Language.Properties.ChbQuestion;
162
  HideCheckBox.Caption := Language.Properties.ChbHide;
163

164
  CommandEdit.Text := Link.exec;
165
  WorkFolderEdit.Text := Link.workdir;
166
  DescrEdit.Text := Link.descr;
167
  ic := Link.icon;
168
  iconindex := Link.iconindex;
169
  QuesCheckBox.Checked := Link.ques;
170
  HideCheckBox.Checked := Link.hide;
171
  WStyleBox.ItemIndex := Link.wst;
172
  FlaunchMainForm.LoadIcFromFileNoModif(IcImage, GetAbsolutePath(Link.icon),
173
    Link.iconindex);
174
  CommandEditChange(nil);
175
end;
176

177
procedure TFilePropertiesForm.RefreshProps;
178
var
179
  lnkinfo: TShellLinkInfoStruct;
180
begin
181
  if (not FileExists(GetAbsolutePath(CommandEdit.Text))) and (not DirectoryExists(GetAbsolutePath(CommandEdit.Text))) then exit;
182

183
  if extractfileext(GetAbsolutePath(CommandEdit.Text)).ToLower = '.lnk' then
184
    begin
185
      StrPLCopy(lnkinfo.FullPathAndNameOfLinkFile, GetAbsolutePath(CommandEdit.Text), MAX_PATH - 1);
186
      GetLinkInfo(@lnkinfo);
187
      CommandEdit.Text := lnkinfo.FullPathAndNameOfFileToExecute;
188
      Ic := lnkinfo.FullPathAndNameOfFileContiningIcon;
189
      if Ic = '' then Ic := CommandEdit.Text;
190
      iconindex := lnkinfo.IconIndex;
191
      WorkFolderEdit.Text := lnkinfo.FullPathAndNameOfWorkingDirectroy;
192
      DescrEdit.Text := lnkinfo.Description;
193
    end
194
  else
195
    begin
196
      //ext := extractfileext(GetAbsolutePath(CommandEdit.Text)).ToLower;
197
      //if not IsExecutable(ext) then exit;
198
      Ic := CommandEdit.Text;
199
      //ParamsEdit.Text := '';
200
      DescrEdit.Text := '';
201
      iconindex := 0;
202
    end;
203
  if DescrEdit.Text = '' then
204
    DescrEdit.Text := ExtractFileName(GetAbsolutePath(CommandEdit.Text));
205
  FlaunchMainForm.LoadIcFromFileNoModif(IcImage, GetAbsolutePath(Ic), iconindex);
206
end;
207

208
procedure TFilePropertiesForm.WorkFolderClick(Sender: TObject);
209
begin
210
  WorkFolderEdit.Text := ExtractFileDir(FileOrDirSelect(WorkFolderEdit.Text));
211
end;
212

213
procedure TFilePropertiesForm.BrowseExecClick(Sender: TObject);
214
begin
215
  CommandEdit.Text := FileOrDirSelect(CommandEdit.Text);
216
end;
217

218
end.
219

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.