Ветеран
Сообщения: 649
Благодарности: 444
Профиль
|
Отправить PM
| Цитировать
подскажите пожалуйста как в этой процедуре обрабатываемой при изменении лист бокса получить текст выбранного айтема
procedure FileListOnClick(Sender: TObject);
begin
// From_Edit.Text := FileList.Items(Sender).Text;
end;
код целиком:
читать дальше »
Код:
[Setup]
AppName=Test
AppVersion=1.0
DefaultDirName={pf}\Test
DefaultGroupName=Test
AllowNoIcons=yes
OutputDir=.
OutputBaseFilename=setup
Compression=lzma
SolidCompression=true
Uninstallable=false
[Languages]
Name: russian; MessagesFile: compiler:Languages\Russian.isl
[ Code]
var
Page: TInputDirWizardPage;
Extract_Button: TButton;
From_Edit: TNewEdit;
From_Button: TNewButton;
To_Edit: TNewEdit;
To_Button: TNewButton;
FileList: TNewListBox;
n: integer;
function GetFileCount(dir: string): Integer;
var
FindFiles: TFindRec;
begin
Result := 0;
if FindFirst(dir + '\*.exe', FindFiles) then
begin
repeat
if FindFiles.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then Result := Result + 1;
until not FindNext(FindFiles) or (Result > 1);
FindClose(FindFiles);
end;
end;
procedure GetAllFiles( Path: string; Lb: TNewListBox );
var
sRec: TFindRec;
isFound: boolean;
begin
isFound := FindFirst(Path +'\*.exe*',sRec);
while isFound do
begin
if (sRec.Name <> '.') and (sRec.Name <> '..') then
begin
if (sRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY then
GetAllFiles(Path + '\' + sRec.Name, Lb);
Lb.Items.Add(Path + sRec.Name);
n := FileList.Items.Count;
end;
Application.ProcessMessages;
isFound := FindNext(sRec);
end;
FindClose(sRec);
end;
procedure FileListOnClick(Sender: TObject);
begin
// From_Edit.Text := FileList.Items(Sender).Text;
end;
procedure BrowseButtonOnClick(Sender: TObject);
var
Dir: String;
MyExit: TSetupForm;
begin
case TButton(Sender) of
From_Button: if BrowseForFolder(SetupMessage(msgBrowseDialogLabel), Dir, False) then
begin
// From_Edit.Text := Dir;
if GetFileCount(Dir) > 1 then
begin
MyExit := CreateCustomForm();
with MyExit do
begin
Position := poScreenCenter;
ClientWidth := ScaleX(400);
ClientHeight := ScaleY(300);
Caption := 'Уточнитель';
Color := clWindow;
with TButton.Create(nil) do
begin
Parent := MyExit;
Caption := ExpandConstant(SetupMessage(msgButtonNo));
SetBounds(ScaleX(18), ScaleY(220), ScaleX(71), ScaleY(25));
Cursor := crHand;
ModalResult:= mrNo;
end;
with TButton.Create(nil) do
begin
Caption := ExpandConstant(SetupMessage(msgButtonYes));
Parent := MyExit;
SetBounds(ScaleX(110), ScaleY(220), ScaleX(71), ScaleY(25));
Cursor := crHand;
ModalResult := mrYes;
end;
FileList := TNewListBox.Create(nil);
with FileList do
begin
Parent := MyExit;
SetBounds(ScaleX(0),ScaleY(0),ScaleX(400),ScaleY(200));
ItemHeight := 13;
ItemIndex := n;
OnClick := @FileListOnClick;
end;
GetAllFiles(Dir, FileList );
case ShowModal() of
mrNo : MsgBox( '', mbError, MB_OK);
mrYes : MsgBox( '', mbError, MB_OK);
end;
end;
end;
end;
To_Button: if BrowseForFolder(SetupMessage(msgBrowseDialogLabel), Dir, True) then To_Edit.Text := Dir;
end;
end;
procedure Edits_OnChange(Sender: TObject);
begin
Extract_Button.Enabled := (From_Edit.Text <> '') and (To_Edit.Text <> '');
end;
procedure Extract(Sender: TObject);
var
ErrorCode: Integer;
begin
Exec(From_Edit.Text, '-y -o"' + To_Edit.Text + '"', From_Edit.Text, SW_HIDE, ewWaitUntilTerminated, ErrorCode);
end;
procedure InitializeWizard();
begin
with WizardForm do
begin
Bevel.Hide;
OuterNotebook.Hide;
end;
From_Edit := TNewEdit.Create(WizardForm);
with From_Edit do
begin
Parent := WizardForm;
Left := ScaleX(64);
Top := ScaleY(168);
Width := ScaleX(313);
Height := ScaleY(21);
OnChange := @Edits_OnChange;
end;
From_Button := TNewButton.Create(WizardForm);
with From_Button do
begin
Caption := 'Обзор';
Parent := WizardForm;
Left := ScaleX(400);
Top := ScaleY(168);
Width := ScaleX(75);
Height := ScaleY(25);
OnClick := @BrowseButtonOnClick;
end;
To_Edit := TNewEdit.Create(WizardForm);
with To_Edit do
begin
Parent := WizardForm;
Left := ScaleX(64);
Top := ScaleY(208);
Width := ScaleX(313);
Height := ScaleY(21);
OnChange := @Edits_OnChange;
end;
To_Button := TNewButton.Create(WizardForm);
with To_Button do
begin
Caption := 'Обзор';
Parent := WizardForm;
Left := ScaleX(400);
Top := ScaleY(208);
Width := ScaleX(75);
Height := ScaleY(25);
OnClick := @BrowseButtonOnClick;
end;
Extract_Button:=TButton.Create(WizardForm);
with Extract_Button do
begin
Parent:=WizardForm;
SetBounds(WizardForm.Width - ScaleX(300),WizardForm.Height - ScaleX(65),ScaleX(75),ScaleY(25));
Caption:='Извлечь';
Enabled := False;
OnClick:=@Extract;
end;
end;
Последний раз редактировалось Johny777, 18-08-2012 в 18:28 .
Это сообщение посчитали полезным следующие участники:
Отправлено : 18:12, 18-08-2012
| #654