2

I am trying to create a new window at Inno Setup. In this window :

  • There should be 5 radio button
  • User must select only one of this choice
  • When the user click the next button I have to get and save the value of the radio button (on somewhere ?) and give this value to the batch file(which will run) with parameter
  • I think I should do some action in the function of NextButtonClick but I cannot figure out how can I reach the value of radio buttons and save.

Any help is appreciated.

The Screenshot of that window :

enter image description here

So now on, my code is like below :

    #define MyAppName "CDV  Client"
    #define MyAppVersion "3.6.1 build 2"
    #define MyAppPublisher " CDV"
    #define MyAppURL "https://example-cm-1"
    #define MyAppExeName "example.exe"


    [Setup]
    AlwaysUsePersonalGroup=true
    ; NOTE: The value of AppId uniquely identifies this application.
    ; Do not use the same AppId value in installers for other applications.
    ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
    AppID={{7C9325AD-6818-42CA-839E}
    AppName={#MyAppName}
    AppVersion={#MyAppVersion}
    ;AppVerName={#MyAppName} {#MyAppVersion}
    AppPublisher={#MyAppPublisher}
    AppPublisherURL={#MyAppURL}
    AppSupportURL={#MyAppURL}
    AppUpdatesURL={#MyAppURL}
    DefaultDirName={code:DriveLetter}:\Tool\CDVClient
    DefaultGroupName=Ser
    AllowNoIcons=true
    OutputBaseFilename=CDVClient_setup
    Compression=lzma/Max
    SolidCompression=true
    SetupLogging=true
    PrivilegesRequired=none
    DirExistsWarning=yes
    AlwaysShowDirOnReadyPage=true
    AlwaysShowGroupOnReadyPage=true

    [Code]
    function DriveLetter(Param: String): String;
    begin
      if DirExists('d:\') then
        Result := 'D'
      else if DirExists('e:\') then
        Result := 'E'
      else
        Result := 'C'
    end;

    var
      CDVRadioButton: TNewRadioButton;
      ISCRadioButton: TNewRadioButton;
      TestRadioButton: TNewRadioButton;
      Test2RadioButton: TNewRadioButton; 
      Test3RadioButton: TNewRadioButton;  
      lblBlobFileFolder: TLabel;

    procedure InitializeWizard;
    var  
      LabelFolder: TLabel;  
      MainPage: TWizardPage;  
      FolderToInstall: TNewEdit;  

    begin
      MainPage := CreateCustomPage(wpWelcome, 'Deneme', 'Deneme2');
      LabelFolder := TLabel.Create(MainPage);
      LabelFolder.Parent := WizardForm;
      LabelFolder.Top := 168;
      LabelFolder.Left := 6;
      LabelFolder.Caption := 'Directory:'

      lblBlobFileFolder :=  TLabel.Create(MainPage);
      lblBlobFileFolder.Parent := MainPage.Surface;
      lblBlobFileFolder.Top := LabelFolder.Top - 160;
      lblBlobFileFolder.Left := LabelFolder.Left;
      lblBlobFileFolder.Width := LabelFolder.Width * 5;
      lblBlobFileFolder.Caption := 'Please select the convenient extension ';

      CDVRadioButton := TNewRadioButton.Create(MainPage);
      CDVRadioButton.Parent := MainPage.Surface;
      CDVRadioButton.Top := LabelFolder.Top - 120;
      CDVRadioButton.Left := LabelFolder.Left;
      CDVRadioButton.Width := LabelFolder.Width * 5;
      CDVRadioButton.Caption := 'CDV';
      CDVRadioButton.Checked := true;

      ISCRadioButton := TNewRadioButton.Create(MainPage);
      ISCRadioButton.Parent := MainPage.Surface;
      ISCRadioButton.Top := LabelFolder.Top - 80;
      ISCRadioButton.Left := LabelFolder.Left;
      ISCRadioButton.Width := LabelFolder.Width * 5;
      ISCRadioButton.Caption := 'ISC';

      TestRadioButton := TNewRadioButton.Create(MainPage);
      TestRadioButton.Parent := MainPage.Surface;
      TestRadioButton.Top := LabelFolder.Top - 40;
      TestRadioButton.Left := LabelFolder.Left;
      TestRadioButton.Width := LabelFolder.Width * 5;
      TestRadioButton.Caption := 'Test1';

      Test2RadioButton := TNewRadioButton.Create(MainPage);
      Test2RadioButton.Parent := MainPage.Surface;
      Test2RadioButton.Top := LabelFolder.Top ;
      Test2RadioButton.Left := LabelFolder.Left;
      Test2RadioButton.Width := LabelFolder.Width * 5;
      Test2RadioButton.Caption := 'Test2';

      Test3RadioButton := TNewRadioButton.Create(MainPage);
      Test3RadioButton.Parent := MainPage.Surface;
      Test3RadioButton.Top := LabelFolder.Top + 40;
      Test3RadioButton.Left := LabelFolder.Left;
      Test3RadioButton.Width := LabelFolder.Width * 5;
      Test3RadioButton.Caption := 'Test3';
    end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
// I should do something in here but what ? :/
end;

    [Languages]
    Name: "english"; MessagesFile: "compiler:Default.isl"

    [Tasks]
    Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
    Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1

    [Files]
    ; add recursesubdirs
    Source: "C:\Program Files\Inno Setup 5\Examples\batu.bat"; DestDir: "{app}"; Flags:  overwritereadonly recursesubdirs
    ; NOTE: Don't use "Flags: ignoreversion" on any shared system files

    [Icons]
    Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
    Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
    Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
    Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
    Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

    [Run]
    Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Batuhan B
  • 1,835
  • 4
  • 29
  • 39

1 Answers1

5

You can check the 'Checked' property of the radio buttons to see which one is selected:

if (CDVRadioButton.Checked) then
begin
   Do stuff...
end
else if (ISCRadioButton.Checked) then
begin
   Do some other stuff...
end;

HTH

alex
  • 161
  • 1
  • 7
  • When i use `function NextButtonClick` it effects every page in the setup process. But i only want to effect my additional page. What should i do for this ? – Batuhan B Dec 10 '13 at 10:11
  • You can check which page you are in in the NextButtonClick function: `if CurPageID = PAGE.ID then begin ... end;` Being PAGE the next page of your MainPage. – alex Dec 10 '13 at 10:23
  • Thanks for your replies but i cannot solve the problem yet, do you know a good documentation or example links for these ? I think the offical page is not very useful. – Batuhan B Dec 10 '13 at 10:51
  • What's the problem now? Could you edit your post with your new code? I usually find useful information in [Inno help](http://www.jrsoftware.org/ishelp) in the Pascal Scripting section (Support functions and Support classes reference). Apart from that, SO has a few examples for almost everything, it's a matter of finding them :) – alex Dec 10 '13 at 10:58
  • You are checking the CurPageID against wpWelcome. wpWelcome is the first page of the installer. Your `MainPage := CreateCustomPage(wpWelcome, 'Deneme', 'Deneme2');` goes straight after wpWelcome. So you need to check CurPageID against the pages that goes AFTER your MainPage. – alex Dec 10 '13 at 11:26
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/42863/discussion-between-batuhan-bardak-and-alex) – Batuhan B Dec 10 '13 at 11:44
  • 4
    Just to add to your discussion. Do not ever hardcode page IDs. The [`TWizardPage`](http://jrsoftware.org/ishelp/topic_scriptclasses.htm#TWizardPage) class has its own `ID` property. Use it. To be specific; make e.g. your `MainPage` variable global and in the `NextButtonClick` event method ask for `if CurPageID = MainPage.ID then`. Be careful on that! P.S. e.g. in [`this post`](http://stackoverflow.com/a/14639971/960757) you might find answers for all your questions (and you might have also seen there, how helper functions improves readability of scripts) `` ;-) – TLama Dec 10 '13 at 23:14
  • @TLama I changed my code like your link, and now `if CDVRadioButton.Checked then` i have to take the value of this button which is `CDV` and give a global variable for use in another window. how can achive this one ? – Batuhan B Dec 11 '13 at 14:57
  • You can read it there. Just my check box object variables are called `ClientButton` and `ServerButton`. It doesn't matter if you access those variables from a different page or a different window. From the script point of view they are still global and can be read in the whole scope of the script. – TLama Dec 11 '13 at 15:03
  • @TLama I see what you mean also I have the last question : After this installation I execute a `exe` file which includes lots of files inside. When this `.exe` file extracted, I have to catch this point and have to give a parameter to a one batch file. This parameter should be a this radio button values. So how can i catch that time ? – Batuhan B Dec 11 '13 at 15:20
  • Hard to say. I don't know that file at all, so I can't tell you what to do. That would require a detailed description when do you execute that file and what that file precisely does. – TLama Dec 11 '13 at 15:30
  • @TLama Okay i ask more general question to you. In the installation this radio button will effect the `.bat` file which is in the `.exe` file. So it is nearly means something should be in dynamically in the installation. For dynamically change the `.exe` file, which topic should i read or do ? – Batuhan B Dec 11 '13 at 15:32
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/42967/discussion-between-batuhan-bardak-and-tlama) – Batuhan B Dec 11 '13 at 15:32