瀏覽代碼

Fix duplicate AddDirButtonClick.

Martijn Laan 1 年之前
父節點
當前提交
c77d79644e
共有 5 個文件被更改,包括 36 次插入60 次删除
  1. 0 1
      Projects/CompFileListWin.dfm
  2. 1 25
      Projects/CompFileListWin.pas
  3. 0 1
      Projects/CompWizard.dfm
  4. 1 20
      Projects/CompWizard.pas
  5. 34 13
      Projects/CompWizardFilesHelper.pas

+ 0 - 1
Projects/CompFileListWin.dfm

@@ -80,7 +80,6 @@ object CFLWForm: TCFLWForm
     Anchors = [akTop, akRight]
     Caption = 'Add fol&der...'
     TabOrder = 3
-    OnClick = AppFilesAddDirButtonClick
   end
   object AppFilesAddButton: TButton
     Left = 514

+ 1 - 25
Projects/CompFileListWin.pas

@@ -19,7 +19,6 @@ type
     AppFilesListBox: TDropListBox;
     AppFilesLabel: TNewStaticText;
     NotCreateAppDirCheck: TCheckBox;
-    procedure AppFilesAddDirButtonClick(Sender: TObject);
     procedure AppFilesEditButtonClick(Sender: TObject);
     procedure AppFilesRemoveButtonClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
@@ -86,29 +85,6 @@ begin
   UpdateHorizontalExtent(AppFilesListBox);
 end;
 
-procedure TCFLWForm.AppFilesAddDirButtonClick(Sender: TObject);
-var
-  Path: String;
-  Recurse: Boolean;
-begin
-  Path := '';
-  if BrowseForFolder(SWizardAppFiles3, Path, Handle, False) then
-  begin
-    case MsgBox(Format(SWizardAppFilesSubDirsMessage, [Path]), '',
-      mbConfirmation, MB_YESNOCANCEL) of
-      idYes:
-        Recurse := True;
-      IDNO:
-        Recurse := False;
-    else
-      Exit;
-    end;
-    AddWizardFile(IncludeTrailingBackslash(Path) + '*', Recurse, Recurse);
-    UpdateWizardFiles;
-  end;
-
-end;
-
 procedure TCFLWForm.AppFilesEditButtonClick(Sender: TObject);
 var
   WizardFileForm: TWizardFileForm;
@@ -168,7 +144,7 @@ end;
 procedure TCFLWForm.FormCreate(Sender: TObject);
 begin
   FFilesHelper := TWizardFormFilesHelper.Create(Handle, FWizardFiles,
-    NotCreateAppDirCheck, AppFilesAddButton, AppFilesListBox);
+    NotCreateAppDirCheck, AppFilesAddButton, AppFilesAddDirButton, AppFilesListBox);
 
   FWizardFiles := FFilesHelper.WizardFiles;
 end;

+ 0 - 1
Projects/CompWizard.dfm

@@ -589,7 +589,6 @@ object WizardForm: TWizardForm
             Anchors = [akTop, akRight]
             Caption = 'Add fol&der...'
             TabOrder = 8
-            OnClick = AppFilesAddDirButtonClick
           end
           object NoAppExeCheck: TCheckBox
             Left = 36

+ 1 - 20
Projects/CompWizard.pas

@@ -146,7 +146,6 @@ type
     procedure NotDisableProgramGroupPageCheckClick(Sender: TObject);
     procedure AppFilesEditButtonClick(Sender: TObject);
     procedure AppFilesRemoveButtonClick(Sender: TObject);
-    procedure AppFilesAddDirButtonClick(Sender: TObject);
     procedure AppFilesListBoxDropFile(Sender: TDropListBox;
       const FileName: String);
     procedure PasswordEditChange(Sender: TObject);
@@ -296,7 +295,7 @@ begin
   FLanguages.Insert(0, LanguagesDefaultIsl);
 
   FFilesHelper := TWizardFormFilesHelper.Create(Handle, FWizardFiles,
-    NotCreateAppDirCheck, AppFilesAddButton, AppFilesListBox);
+    NotCreateAppDirCheck, AppFilesAddButton, AppFilesAddDirButton, AppFilesListBox);
 
   FWizardFiles := FFilesHelper.WizardFiles;
 
@@ -774,24 +773,6 @@ begin
     AppFilesEditButton.Click;
 end;
 
-procedure TWizardForm.AppFilesAddDirButtonClick(Sender: TObject);
-var
-  Path: String;
-  Recurse: Boolean;
-begin
-  Path := '';
-  if BrowseForFolder(SWizardAppFiles3, Path, Handle, False) then begin
-    case MsgBox(Format(SWizardAppFilesSubDirsMessage, [Path]), '', mbConfirmation, MB_YESNOCANCEL) of
-      IDYES: Recurse := True;
-      IDNO: Recurse := False;
-    else
-      Exit;
-    end;
-    AddWizardFile(AddBackslash(Path) + '*', Recurse, Recurse);
-    UpdateWizardFiles;
-  end;
-end;
-
 procedure TWizardForm.AppFilesListBoxDropFile(Sender: TDropListBox;
   const FileName: String);
 begin

+ 34 - 13
Projects/CompWizardFilesHelper.pas

@@ -12,27 +12,29 @@ type
       FWizardFiles: TList;
       FHandle: HWND;
       FNotCreateAppDirCheck: TCheckBox;
-      FAppFilesListBox: TDropListBox;
+      FFilesListBox: TDropListBox;
       procedure AddWizardFile(const Source: String; const RecurseSubDirs, CreateAllSubDirs: Boolean);
       procedure UpdateWizardFiles;
       procedure AddButtonClick(Sender: TObject);
+      procedure AddDirButtonClick(Sender: TObject);
     public
       property WizardFiles: TList read FWizardFiles;
       constructor Create(const Handle: HWND; const WizardFiles: TList;
-        const NotCreateAppDirCheck: TCheckBox; const AppFilesAddButton: TButton;
-        const AppFilesListBox: TDropListBox);
-      destructor Destroy;
+        const NotCreateAppDirCheck: TCheckBox; const AddButton, AddDirButton: TButton;
+        const FilesListBox: TDropListBox);
+      destructor Destroy; override;
   end;
 
 implementation
 
 uses
-  CmnFunc, BrowseFunc,
+  SysUtils,
+  CmnFunc, BrowseFunc, PathFunc,
   CompMsgs, CompWizardFile;
 
 constructor TWizardFormFilesHelper.Create(const Handle: HWND;
   const WizardFiles: TList; const NotCreateAppDirCheck: TCheckBox;
-  const AppFilesAddButton: TButton; const AppFilesListBox: TDropListBox);
+  const AddButton, AddDirButton: TButton; const FilesListBox: TDropListBox);
 begin
   inherited Create;
 
@@ -40,9 +42,10 @@ begin
 
   FHandle := Handle;
   FNotCreateAppDirCheck := NotCreateAppDirCheck;
-  FAppFilesListBox := AppFilesListBox;
+  FFilesListBox :=FilesListBox;
 
-  AppFilesAddButton.OnClick := AddButtonClick;
+  AddButton.OnClick := AddButtonClick;
+  AddDirButton.OnClick := AddDirButtonClick;
 end;
 
 destructor TWizardFormFilesHelper.Destroy;
@@ -74,14 +77,14 @@ var
   WizardFile: PWizardFile;
   I: Integer;
 begin
-  FAppFilesListBox.Items.BeginUpdate;
-  FAppFilesListBox.Items.Clear;
+  FFilesListBox.Items.BeginUpdate;
+  FFilesListBox.Items.Clear;
   for I := 0 to FWizardFiles.Count-1 do begin
     WizardFile := FWizardFiles[i];
-    FAppFilesListBox.Items.Add(WizardFile.Source);
+    FFilesListBox.Items.Add(WizardFile.Source);
   end;
-  FAppFilesListBox.Items.EndUpdate;
-  UpdateHorizontalExtent(FAppFilesListBox);
+  FFilesListBox.Items.EndUpdate;
+  UpdateHorizontalExtent(FFilesListBox);
 end;
 
 procedure TWizardFormFilesHelper.AddButtonClick(Sender: TObject);
@@ -102,4 +105,22 @@ begin
   end
 end;
 
+procedure TWizardFormFilesHelper.AddDirButtonClick(Sender: TObject);
+var
+  Path: String;
+  Recurse: Boolean;
+begin
+  Path := '';
+  if BrowseForFolder(SWizardAppFiles3, Path, FHandle, False) then begin
+    case MsgBox(Format(SWizardAppFilesSubDirsMessage, [Path]), '', mbConfirmation, MB_YESNOCANCEL) of
+      IDYES: Recurse := True;
+      IDNO: Recurse := False;
+    else
+      Exit;
+    end;
+    AddWizardFile(AddBackslash(Path) + '*', Recurse, Recurse);
+    UpdateWizardFiles;
+  end;
+end;
+
 end.