2016-03-05 109 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

是的!非常感謝。在最後一次編輯之後,它可以工作(第一個,顯然也影響了其他組件組合)。這似乎很愚蠢,解決方案非常簡單,我對所有數字/組合和內容感到困惑。我發誓,那天我可以在腦海裏完成這一切,把它寫入腳本會容易得多。 –

相關問題