在Inno Setup中,您可以拥有一个TInputFileWizardPage,其中包含一个不错的文件选择小工具。但是,您可以将相同的小工具放在通用的TWizardPage上吗?具体来说,我想使用单选按钮,以便在激活一个特定选项时使用文件小工具。
修改创建的TInputFileWizardPage
页面比构建自己的输入文件页面更容易。以下示例添加了两个单选按钮,并移动了输入文件项的组件。默认情况下,禁用输入文件组件,并选择第一个单选按钮。如果用户选择第二个单选按钮,则启用输入文件组件:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
var
InputPage: TInputFileWizardPage;
RadioButtons: array[0..1] of TNewRadioButton;
procedure ShiftFilePageItem(Page: TInputFileWizardPage; Index: Integer;
Offset: Integer);
begin
Page.Edits[Index].Top := Page.Edits[Index].Top + Offset;
Page.Buttons[Index].Top := Page.Buttons[Index].Top + Offset;
Page.PromptLabels[Index].Top := Page.PromptLabels[Index].Top + Offset;
end;
procedure SetFilePageItemEnabled(Page: TInputFileWizardPage; Index: Integer;
Enabled: Boolean);
begin
Page.Edits[Index].Enabled := Enabled;
Page.Buttons[Index].Enabled := Enabled;
Page.PromptLabels[Index].Enabled := Enabled;
end;
procedure RadioButtonClick(Sender: TObject);
begin
SetFilePageItemEnabled(InputPage, 0, Sender = RadioButtons[1]);
end;
procedure InitializeWizard;
begin
InputPage := CreateInputFilePage(wpWelcome, 'Caption', 'Description',
'SubCaption');
InputPage.Add('Prompt', 'All files|*.*', '*.*');
RadioButtons[0] := TNewRadioButton.Create(InputPage);
RadioButtons[0].Parent := InputPage.Surface;
RadioButtons[0].Left := 0;
RadioButtons[0].Top := 0;
RadioButtons[0].Width := InputPage.SurfaceWidth;
RadioButtons[0].Checked := True;
RadioButtons[0].Caption := 'Option with no file selection';
RadioButtons[0].OnClick := @RadioButtonClick;
RadioButtons[1] := TNewRadioButton.Create(InputPage);
RadioButtons[1].Parent := InputPage.Surface;
RadioButtons[1].Left := RadioButtons[0].Left;
RadioButtons[1].Top := RadioButtons[0].Top + RadioButtons[0].Height + 2;
RadioButtons[1].Width := InputPage.SurfaceWidth;
RadioButtons[1].Checked := False;
RadioButtons[1].Caption := 'Option with file selection';
RadioButtons[1].OnClick := @RadioButtonClick;
ShiftFilePageItem(InputPage, 0, RadioButtons[1].Top);
SetFilePageItemEnabled(InputPage, 0, False);
end;
默认情况下,页面是这样的:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句