选择任务时显示图像
Display an image when a task is selected
我希望选中其中一个任务时显示不同的图像。
例如,如果我有三个不同的任务:
Task 1: Standard version
Task 2: Lite version
Task 3: Pro version
- 选中任务 1 时必须显示图像。
- 选中任务 2 时必须隐藏任务 1 图像并显示任务 2 图像。
- 选中任务 3 时必须将其他任务隐藏在任务图像下方并显示任务 3 图像。
这里是一些代码
[Code]
{ RedesignWizardFormBegin } { Don't remove this line! }
{ Don't modify this section. It is generated automatically. }
var
BitmapImage1: TBitmapImage;
procedure RedesignWizardForm;
begin
{ BitmapImage1 }
BitmapImage1 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage1.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage1.bmp'));
end;
with WizardForm.TasksList do
begin
Width := ScaleX(257);
Height := ScaleY(200);
Visible := False;
end;
end;
添加 OnClickCheck 事件:
例如:
var
BitmapImage1: TBitmapImage;
BitmapImage2: TBitmapImage;
BitmapImage3: TBitmapImage;
procedure TasksListClickCheck(Sender: TObject);
begin
if (WizardForm.TasksList.Checked[0] = True) then
begin
BitmapImage1 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage1.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage1.bmp'));
end;
end;
if (WizardForm.TasksList.Checked[1] = True) then
begin
BitmapImage2 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage2.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage2.bmp'));
end;
end;
if (WizardForm.TasksList.Checked[2] = True) then
begin
BitmapImage3 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage3.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage3.bmp'));
end;
end;
end;
procedure InitializeWizard;
begin
WizardForm.TasksList.OnClickCheck := @TasksListClickCheck
with WizardForm.TasksList do
begin
Width := ScaleX(257);
Height := ScaleY(200);
Visible := True;
end;
end;
- 使用
WizardIsTaskSelected
(IsTaskSelected
在旧版本的 Inno Setup 中)找出哪些任务已经 selected。
- 处理
WizardForm.TasksList.OnClickCheck
和 CurPageChanged
以检测 select 离子变化并相应地更新图像。
[Files]
Source: "lite.bmp"; Flags: dontcopy
Source: "pro.bmp"; Flags: dontcopy
Source: "std.bmp"; Flags: dontcopy
[Tasks]
Name: std; Description: "Standard version"; Flags: exclusive
Name: lite; Description: "Lite version"; Flags: exclusive
Name: pro; Description: "Pro version"; Flags: exclusive
[Code]
var
BitmapImage1: TBitmapImage;
procedure UpdateTasksImage;
var
Image: string;
begin
if WizardIsTaskSelected('pro') then Image := 'pro.bmp'
else
if WizardIsTaskSelected('lite') then Image := 'lite.bmp'
else
if WizardIsTaskSelected('std') then Image := 'std.bmp'
else Image := '';
if Image <> '' then
begin
ExtractTemporaryFile(Image);
BitmapImage1.Bitmap.LoadFromFile(ExpandConstant('{tmp}\' + Image));
BitmapImage1.Visible := True;
end
else
begin
BitmapImage1.Visible := False;
end;
end;
procedure TasksListClickCheck(Sender: TObject);
begin
{ Update image, when task selection changes }
UpdateTasksImage;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
{ Update image, when task page is entered }
{ (as tasks can be selected by changing setup type or components) }
if CurPageID = wpSelectTasks then
begin
UpdateTasksImage;
end;
end;
procedure InitializeWizard;
begin
BitmapImage1 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
end;
with WizardForm.TasksList do
begin
Width := ScaleX(257);
Height := ScaleY(200);
end;
WizardForm.TasksList.OnClickCheck := @TasksListClickCheck
end;
尽管在我看来,您的 "tasks" 实际上应该是安装类型或组件。对我来说,用户可以 select "standard"、"lite" 和 "pro" 的组合 是没有意义的。这些不应该是 distinct 选项吗?
我希望选中其中一个任务时显示不同的图像。
例如,如果我有三个不同的任务:
Task 1: Standard version
Task 2: Lite version
Task 3: Pro version
- 选中任务 1 时必须显示图像。
- 选中任务 2 时必须隐藏任务 1 图像并显示任务 2 图像。
- 选中任务 3 时必须将其他任务隐藏在任务图像下方并显示任务 3 图像。
这里是一些代码
[Code]
{ RedesignWizardFormBegin } { Don't remove this line! }
{ Don't modify this section. It is generated automatically. }
var
BitmapImage1: TBitmapImage;
procedure RedesignWizardForm;
begin
{ BitmapImage1 }
BitmapImage1 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage1.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage1.bmp'));
end;
with WizardForm.TasksList do
begin
Width := ScaleX(257);
Height := ScaleY(200);
Visible := False;
end;
end;
添加 OnClickCheck 事件: 例如:
var
BitmapImage1: TBitmapImage;
BitmapImage2: TBitmapImage;
BitmapImage3: TBitmapImage;
procedure TasksListClickCheck(Sender: TObject);
begin
if (WizardForm.TasksList.Checked[0] = True) then
begin
BitmapImage1 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage1.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage1.bmp'));
end;
end;
if (WizardForm.TasksList.Checked[1] = True) then
begin
BitmapImage2 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage2.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage2.bmp'));
end;
end;
if (WizardForm.TasksList.Checked[2] = True) then
begin
BitmapImage3 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
ExtractTemporaryFile('WizardForm.BitmapImage3.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage3.bmp'));
end;
end;
end;
procedure InitializeWizard;
begin
WizardForm.TasksList.OnClickCheck := @TasksListClickCheck
with WizardForm.TasksList do
begin
Width := ScaleX(257);
Height := ScaleY(200);
Visible := True;
end;
end;
- 使用
WizardIsTaskSelected
(IsTaskSelected
在旧版本的 Inno Setup 中)找出哪些任务已经 selected。 - 处理
WizardForm.TasksList.OnClickCheck
和CurPageChanged
以检测 select 离子变化并相应地更新图像。
[Files]
Source: "lite.bmp"; Flags: dontcopy
Source: "pro.bmp"; Flags: dontcopy
Source: "std.bmp"; Flags: dontcopy
[Tasks]
Name: std; Description: "Standard version"; Flags: exclusive
Name: lite; Description: "Lite version"; Flags: exclusive
Name: pro; Description: "Pro version"; Flags: exclusive
[Code]
var
BitmapImage1: TBitmapImage;
procedure UpdateTasksImage;
var
Image: string;
begin
if WizardIsTaskSelected('pro') then Image := 'pro.bmp'
else
if WizardIsTaskSelected('lite') then Image := 'lite.bmp'
else
if WizardIsTaskSelected('std') then Image := 'std.bmp'
else Image := '';
if Image <> '' then
begin
ExtractTemporaryFile(Image);
BitmapImage1.Bitmap.LoadFromFile(ExpandConstant('{tmp}\' + Image));
BitmapImage1.Visible := True;
end
else
begin
BitmapImage1.Visible := False;
end;
end;
procedure TasksListClickCheck(Sender: TObject);
begin
{ Update image, when task selection changes }
UpdateTasksImage;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
{ Update image, when task page is entered }
{ (as tasks can be selected by changing setup type or components) }
if CurPageID = wpSelectTasks then
begin
UpdateTasksImage;
end;
end;
procedure InitializeWizard;
begin
BitmapImage1 := TBitmapImage.Create(WizardForm);
with BitmapImage1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(320);
Top := ScaleY(88);
Width := ScaleX(57);
Height := ScaleY(57);
end;
with WizardForm.TasksList do
begin
Width := ScaleX(257);
Height := ScaleY(200);
end;
WizardForm.TasksList.OnClickCheck := @TasksListClickCheck
end;
尽管在我看来,您的 "tasks" 实际上应该是安装类型或组件。对我来说,用户可以 select "standard"、"lite" 和 "pro" 的组合 是没有意义的。这些不应该是 distinct 选项吗?