2016-03-05 75 views
1
[Components] 
Name: "Slasher"; Description: "Dagon Slasher"; Types: Slasher Full 
Name: "Frankenstein"; Description: "Dagon Frankenstein"; Types: Frankenstein Full 

[Types] 
Name: "Full"; Description: "Dagon Video Tools" 
Name: "Slasher"; Description: "Dagon Slasher" 
Name: "Frankenstein"; Description: "Dagon FrankenStein" 

[Tasks] 
Name: "Debug"; Description: "Nothing"; Components: not Slasher 
Name: "Vid"; Description: "Install Extra Codecs for Frankenstein"; Flags: unchecked; Components: not Slasher 

[Code] 
var 
    Warning: TNewStaticText; 

procedure InitializeWizard; 
begin 
    Warning := TNewStaticText.Create(WizardForm); 
    Warning.Parent := WizardForm.SelectTasksPage; 
    Warning.Visible := False; 
    Warning.AutoSize := False; 
    Warning.SetBounds(
    WizardForm.TasksList.Left, 
    WizardForm.TasksList.Top + WizardForm.TasksList.Height, 
    WizardForm.TasksList.Width, 
    50 
); 
    Warning.Font.Color := clRed; 
    Warning.Caption := 'Warning: This will result in a non-functional "Join in FrankenStein" button in the Tools Menu.'; 
end; 

我还使用了另一个惊人的code by TLama。问题是我需要在用户选择任务时显示注释,否则将隐藏(同一页面上)。Inno Setup - 根据任务选择有条件地隐藏/显示静态文本

回答

1

您必须处理WizardForm.TasksList.OnClickCheck事件并相应地更新Warning标签的可见性。

var 
    Warning: TNewStaticText; 

procedure TasksListClickCheck(Sender: TObject); 
begin 
    Warning.Visible := 
    { This (and the task index below) has to be kept in sync with the expression } 
    { in "Components" parameter of the respective task. } 
    { Though note that in your specific case the test } 
    { is redundant as when "Slasher" is selected, you have no tasks, } 
    { and the "Tasks" page is completely skipped, so you do not even get here. } 
    (not IsComponentSelected('Slasher')) and 
    WizardForm.TasksList.Checked[0]; 
end; 

procedure InitializeWizard; 
begin 
    Warning := TNewStaticText.Create(WizardForm); 
    ... 
    { Update Warning label visibility on task selection change } 
    WizardForm.TasksList.OnClickCheck := @TasksListClickCheck 
end; 

procedure CurPageChanged(CurPageID: Integer); 
begin 
    if CurPageID = wpSelectTasks then 
    begin 
    // Update initial visibility 
    TasksListClickCheck(WizardForm.TasksList); 
    end; 
end; 

Task selected

Task unselected


旁注:

  • 不要硬编码的高度固定50。使用DPI进行缩放:ScaleY(50)
  • 您应该设置Warning.WordWrap := True作为标题不符合页面宽度。
  • 您应该缩小TasksList的高度,因为标签不在列表下方。您错过了@ TLama代码中的WizardForm.TasksList.Height := WizardForm.TasksList.Height - NoteHeight;。再次请注意,他错过了NoteHeight的缩放比例。
const 
    NoteHeight = 50; 

procedure InitializeWizard; 
begin 
    WizardForm.TasksList.Height := WizardForm.TasksList.Height - ScaleY(NoteHeight); 

    Warning := TNewStaticText.Create(WizardForm); 
    Warning.Parent := WizardForm.SelectTasksPage; 
    Warning.AutoSize := False; 
    Warning.WordWrap := True; 
    Warning.SetBounds(
    WizardForm.TasksList.Left, 
    WizardForm.TasksList.Top + WizardForm.TasksList.Height, 
    WizardForm.TasksList.Width, 
    ScaleY(NoteHeight) 
); 
    Warning.Font.Color := clRed; 
    { Update Warning label visibility on task selection change } 
    WizardForm.TasksList.OnClickCheck := @TasksListClickCheck 
    Warning.Caption := 
    'Warning: This will result in a non-functional "Join in FrankenStein" button ' + 
    'in the Tools Menu.'; 
end; 
+1

是的!非常感谢。在最后一次编辑之后,它可以工作(第一个,显然也影响了其他组件组合)。这似乎很愚蠢,解决方案非常简单,我对所有数字/组合和内容感到困惑。我发誓,那天我可以在脑海里完成这一切,把它写入脚本会容易得多。 –

相关问题