Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hook standard Inno Setup checkbox

Tags:

inno-setup

I added an InputOptionWizardPage for selecting tasks. This works fine, but I would like to add some custom functionality. One task is dependent on the other, so if the second checkbox is checked, the first should be checked and grayed out.

To do this, I need to access the properties of a checkbox. I found ways to do this using a completely custom page, where I would explicitly create the checkbox myself, but that would be a lot of work, since most of what I have so far is satisfactory.

How can I hook a checkbox that was created by Inno Setup, using MyInputOptionWizardPage.Add('This will add a checkbox with this caption')?

like image 501
thoiz_vd Avatar asked May 01 '11 22:05

thoiz_vd


1 Answers

In attempt to answer your question directly.

I suspect you have used CreateInputOptionPage() which returns a TInputOptionWizardPage

This has the '.Add('Example')` method that you mention.

TInputOptionWizard descends TWizardPage which descends from TComponent which has the methods you need.

Update: Replaced original Code, this example is based on a review of options available in the InnoSetup source code of ScriptClasses_C.pas My original example I thought that TRadioButton and TCheckBox where individual controls. They instead its one control called TNewCheckListBox. There is a couple of ways someone could pull this off but the safest way is to use.

This example is a complete Inno Setup Script.

[Setup]
AppName='Test Date Script'
AppVerName='Test Date Script'
DefaultDirName={pf}\test
[Code]

const
 cCheckBox = false;
 cRadioButton  = true;


var
  Opt : TInputOptionWizardPage; 

function BoolToStr(Value : Boolean) : String; 
begin
  if Value then
    result := 'true'
  else
    result := 'false';
end;

procedure ClickEvent(Sender : TObject);
var
 Msg : String;
 I   : Integer;
begin
   // Click Event, allowing inspection of the Values.
    Msg := 'The Following Items are Checked' +#10#13; 
    Msg := Msg + 'Values[0]=' + BoolToStr(Opt.Values[0]) +#10#13;
    Msg := Msg + 'Values[1]=' + BoolToStr(Opt.Values[1]) +#10#13;
    Msg := Msg + 'Values[2]=' + BoolToStr(Opt.Values[2]);

    MsgBox(Msg,mbInformation,MB_OK);
end;
procedure InitializeWizard();
var
  I : Integer; 
  ControlType : Boolean;
begin
  ControlType := cCheckBox;
  Opt := CreateInputOptionPage(1,'Caption','Desc','SubCaption',ControlType, false);
  Opt.Add('Test1');
  Opt.Add('Test2');
  Opt.Add('Test3');

  // Assign the Click Event.
  Opt.CheckListBox.OnClickCheck := @ClickEvent;  
end;
like image 107
Robert Love Avatar answered Sep 21 '22 07:09

Robert Love