Используйте FindFirst
/ FindNext
, чтобы найти ваши папки.
А затем вы можете поместить их, например, в TNewCheckListBox
. Скрыть DirEdit
. И обновите его скрытое содержимое в зависимости от того, какой пользователь выбрал в TNewCheckListBox
[Code]
var
DirCheckListBox: TNewCheckListBox;
Dirs: TStringList;
procedure DirCheckListBoxClick(Sender: TObject);
begin
{ When user changes selection, update the path in hidden edit box }
WizardForm.DirEdit.Text := Dirs[DirCheckListBox.ItemIndex];
end;
procedure InitializeWizard();
var
FindRec: TFindRec;
RootPath: string;
Path: string;
Name: AnsiString;
begin
DirCheckListBox := TNewCheckListBox.Create(WizardForm);
DirCheckListBox.Parent := WizardForm.DirEdit.Parent;
DirCheckListBox.Top := WizardForm.SelectDirBrowseLabel.Top;
DirCheckListBox.Left := WizardForm.DirEdit.Left;
DirCheckListBox.Width := WizardForm.DirEdit.Width;
DirCheckListBox.Height :=
WizardForm.DiskSpaceLabel.Top - DirCheckListBox.Top - ScaleY(8);
DirCheckListBox.Color := WizardForm.TasksList.Color;
DirCheckListBox.WantTabs := WizardForm.TasksList.WantTabs;
DirCheckListBox.MinItemHeight := WizardForm.TasksList.MinItemHeight;
DirCheckListBox.ParentColor := WizardForm.TasksList.ParentColor;
DirCheckListBox.BorderStyle := WizardForm.TasksList.BorderStyle;
WizardForm.DirEdit.Visible := False;
WizardForm.DirBrowseButton.Visible := False;
WizardForm.SelectDirBrowseLabel.Visible := False;
RootPath := ExpandConstant('{pf}\App');
Dirs := TStringList.Create;
if FindFirst(RootPath + '\*', FindRec) then
begin
repeat
if ((FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0) and
(FindRec.Name <> '.') and
(FindRec.Name <> '..') then
begin
Path := RootPath + '\' + FindRec.Name;
{ LoadStringFromFile can handle only ascii/ansi files, no Unicode }
if LoadStringFromFile(Path + '\' + 'version.txt', Name) then
begin
Dirs.Add(Path);
DirCheckListBox.AddRadioButton(Name, '', 0, False, True, nil);
{ If already installed, check the path that was selected previously, }
{ otherwise check the first one }
if (DirCheckListBox.Items.Count = 1) or
(CompareText(WizardForm.DirEdit.Text, Path) = 0) then
begin
DirCheckListBox.ItemIndex := DirCheckListBox.Items.Count - 1;
DirCheckListBox.Checked[DirCheckListBox.ItemIndex] := True;
end;
end;
end;
until not FindNext(FindRec);
end;
if DirCheckListBox.Items.Count = 0 then
begin
RaiseException('No folder found.');
end;
DirCheckListBox.OnClickCheck := @DirCheckListBoxClick;
DirCheckListBoxClick(nil);
end;