mardi 3 janvier 2017

INNOSETUP How to get Checkbox or optionbutton value in a checklistbox?

I thought it was something simple to code, but the fact is that I'm finally facing issue about getting back checked/unchecked value of checkboxes and radiobuttons in a CheckListBox.

I tried to set the checkboxes and radiobutton as global instance so that I can easily access it in the NextButtonClick event. But in this sample test I get a "Could not call proc." Error :

[Setup]
AppName=Test
AppVersion=1
DefaultDirName={pf}\Test

[Code]
var
  PageChoixComposants: TWizardPage;
  CB1, CB2: TNewCheckBox;
  OB1, OB2: TNewRadioButton; 

procedure InitializeWizard;
var
  ListBox: TNewListBox;
  CheckListBox: TNewCheckListBox;
begin

  PageChoixComposants := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TNewCheckListBox');

  CheckListBox := TNewCheckListBox.Create(PageChoixComposants);
  CheckListBox.Width := PageChoixComposants.SurfaceWidth;
  CheckListBox.Height := ScaleY(97);
  CheckListBox.Flat := True;
  CheckListBox.Parent := PageChoixComposants.Surface;
  CB1 := CheckListBox.AddCheckBox('CB1', '', 0, True, True, False, True, nil);
  OB1 := CheckListBox.AddRadioButton('CB1 OB1', '', 1, True, True, nil);
  OB2 := CheckListBox.AddRadioButton('CB1 OB2', '', 1, False, True, nil);
  CB2 := CheckListBox.AddCheckBox('CB2', '', 0, True, True, False, True, nil);
end;

//////////////////////////////////////////////////////////////////////
function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if (CurPageID=PageChoixComposants.ID) then
    begin      
      if CB1.Checked = True then
        begin
          MsgBox('CB1 checked', mbInformation, MB_OK);
        end;
    end;
  Result := True;
end;

//////////////////////////////////////////////////////////////////////

What goes wrong here? Thanks for your replies ;)




Aucun commentaire:

Enregistrer un commentaire