2017-07-12 1 views
2

Je souhaite que les tâches affichent une image différente lorsque l'une d'entre elles est cochée.Afficher une image lorsqu'une tâche est sélectionnée

Par exemple, si j'ai trois tâches différentes:

Task 1: Standard version 
Task 2: Lite version 
Task 3: Pro version 
  • lorsque la tâche 1 est cochée doit afficher une image.
  • lorsque la tâche 2 est cochée, elle doit masquer l'image de la tâche 1 et afficher l'image de la tâche 2.
  • Lorsque la tâche 3 est cochée, elle doit cacher les autres sous l'image des tâches et afficher l'image de la tâche 3.

Voici un code

[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; 

Répondre

1
  • Utilisez IsTaskSelected pour savoir quelles tâches ont abeille n sélectionné.
  • Saisissez WizardForm.TasksList.OnClickCheck et CurPageChanged pour détecter les modifications de sélection et mettre à jour l'image en conséquence.
[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 IsTaskSelected('pro') then Image := 'pro.bmp' 
    else 
    if IsTaskSelected('lite') then Image := 'lite.bmp' 
    else 
    if IsTaskSelected('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; 

enter image description here

enter image description here


Bien qu'il me semble, que vos "tâches" devrait effectivement être les types de configuration ou de composants. Cela n'a pas de sens pour moi qu'un utilisateur puisse sélectionner combinaisons de "standard", "lite" et "pro". Est-ce que ce ne devrait pas être une distincte des options?

+0

Oui, si l'un d'eux est coché, les deux autres doivent être décochés. – Thebig1825

+0

Alors pourquoi afficher des cases à cocher dans votre question? Ceux-ci devraient être des boutons radio. Et encore, alors ce ne sont pas des tâches, mais des types d'installation ou des composants. –

+0

En tout cas, j'ai répondu à votre question. –

0

Ajouter OnClickCheck événement: Par exemple:

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;