Statistiques
| Révision:

root / UnitRename.pas @ 1

Historique | Voir | Annoter | Télécharger (2,164 ko)

1 1 avalancogn
unit UnitRename;
2
3
interface
4
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  Dialogs, StdCtrls, gnugettext, ImgList, ActnList, JvExStdCtrls, JvButton,
8
  JvCtrls, ExtCtrls;
9
10
type
11
  TFormRename = class(TForm)
12
    EditName: TEdit;
13
    JvImgBtnCancel: TJvImgBtn;
14
    JvImgBtnOK: TJvImgBtn;
15
    ActionListButtons: TActionList;
16
    ActionOK: TAction;
17
    ActionCancel: TAction;
18
    ImageListIcons: TImageList;
19
    PanelButtons: TPanel;
20
    procedure FormCreate(Sender: TObject);
21
    procedure FormShow(Sender: TObject);
22
    procedure FormDestroy(Sender: TObject);
23
    procedure ActionOKExecute(Sender: TObject);
24
    procedure ActionCancelExecute(Sender: TObject);
25
  private
26
    { D?clarations priv?es }
27
  public
28
    { D?clarations publiques }
29
    OldName, NewName: String;
30
    NameList: TStrings;
31
  end;
32
33
var
34
  FormRename: TFormRename;
35
36
implementation
37
38
uses
39
  UnitDeclaration;
40
41
{$R *.dfm}
42
43
procedure TFormRename.ActionCancelExecute(Sender: TObject);
44
begin
45
  ModalResult := mrCancel;
46
end;
47
48
procedure TFormRename.ActionOKExecute(Sender: TObject);
49
begin
50
  NewName := Trim(EditName.Text);
51
  if OldName <> NewName
52
  then // V?rifier
53
  begin
54
    if NewName = ''
55
    then
56
    begin
57
      MessageDlg(_('The name is mandatory, please enter a non-empty string.'), mtError, [mbOK], 0);
58
      ActiveControl := EditName;
59
      Exit;
60
    end;
61
    if NameList.IndexOf(NewName) <> -1
62
    then
63
    begin
64
      MessageDlg(_('This name is already used, please specify another name.'), mtError, [mbOK], 0);
65
      ActiveControl := EditName;
66
      Exit;
67
    end;
68
  end;
69
  ModalResult := mrOk;
70
end;
71
72
procedure TFormRename.FormCreate(Sender: TObject);
73
begin
74
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
75
  then
76
    Font.Name := 'Arial Unicode MS';
77
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
78
  PanelButtons.Font.Style := [fsBold];
79
  TranslateComponent(Self);
80
  NameList := TStringList.Create;
81
end;
82
83
procedure TFormRename.FormDestroy(Sender: TObject);
84
begin
85
  NameList.Free;
86
end;
87
88
procedure TFormRename.FormShow(Sender: TObject);
89
begin
90
  EditName.Text := OldName;
91
  EditName.SelectAll;
92
end;
93
94
end.