0

In the Inno script, I am using the language selection drop down. I am also storing the selected language to a file called "language.properties" using the below code. The installed application uses this "language.properties" file.

procedure CurStepChanged(CurStep: TSetupStep);
var
  S: string;
begin
  if CurStep = ssPostInstall then
  begin
    S := Format('language=%s', [ActiveLanguage]);
    SaveStringToFile(ExpandConstant('{app}') + '\language.properties', S, False);
  end;
end;

Language selection

Now apart from language selection, I need to add a region selection drop down. The values for the regions is custom, (like America, Europe etc) meaning which there is no need to take from the windows registry.

When the user has selected the region, I need to store that to the same file "language.properties"

I am very new to Inno script. What do you think? How can this be done efficiently?

Edit: Since form the initial comments, it is not possible to customize the "Select Setup Language" dialog, how to add a custom wizard page for region selection?

Balaji Vignesh
  • 446
  • 1
  • 7
  • 19
  • As far as I am aware there is no facility to customise the actual language selection window. This sounds more like a feature request and might be best asked on the Inno Setup newsgroup. However there are others here on StackOverflow with a lot more knowledge than me who might know how to do it. – Andrew Truckle Mar 05 '18 at 09:00
  • The only thing that springs to my mind is to add a **custom wizard page** into the install process with the drop list on it as opposed to trying to customise the `LanguageDialog`. – Andrew Truckle Mar 05 '18 at 09:06
  • I have edited the question based on your suggestion. Any examples of adding a **Custom Wizard Page** ? – Balaji Vignesh Mar 05 '18 at 09:15
  • There is an example here https://github.com/jrsoftware/issrc/blob/master/Examples/CodeDlg.iss. Please let me know if you need more help. – Andrew Truckle Mar 05 '18 at 09:17
  • 1
    Additionally, there are zillions of other questions here already on creating a custom wizard page. – Martin Prikryl Mar 05 '18 at 09:24
  • I have seen that example. There is a radio button, text box but for my use case, I need a drop down. – Balaji Vignesh Mar 05 '18 at 09:25
  • @BalajiVignesh I have added an example as an anser for you. – Andrew Truckle Mar 05 '18 at 09:47
  • To reimplement the language selection dialog, see [Inno Setup - Language selector with VCL Styles](https://stackoverflow.com/q/41021292/850848). – Martin Prikryl Mar 06 '18 at 08:33

1 Answers1

1

This is a snippet of my application settings page. I have cut it down:

function AppSettings_CreatePage(PreviousPageId: Integer): Integer;
var
    Page: TWizardPage;
    iUserValue: Cardinal;
    strPath: String;
begin
    Page := CreateCustomPage(
        PreviousPageId,
        ExpandConstant('{cm:ApplicationPreferences}'),
        ExpandConstant('{cm:DefaultSettings}')
    );

    // lblInfo
    lblInfo := TLabel.Create(Page);
    with lblInfo do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:SpecifyDefaultSettings}');
        Left := ScaleX(8);
        Top := ScaleY(8);
        Width := ScaleX(387);
        Height := ScaleY(29);
    end;

    // lblDatabase
    lblDatabase := TLabel.Create(Page);
    with lblDatabase do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:DatabaseLanguage}');
        Left := ScaleX(8);
        Top := ScaleY(112);
        Width := ScaleX(385);
        Height := ScaleY(13);
    end;

    // cbDatabase
    cbDatabase := TNewComboBox.Create(Page);
    with cbDatabase do
    begin
        Parent := Page.Surface;
        Left := ScaleX(8);
        Top := ScaleY(128);
        Width := ScaleX(177);
        Height := ScaleY(21);
        Style := csDropDownList;
        TabOrder := 3;

        // Languages
        Items.Add({#LANG_AFK});
        Items.Add({#LANG_TWI});
        Items.Add({#LANG_DAN});
        Items.Add({#LANG_DEU});
        Items.Add({#LANG_ENG});
        Items.Add({#LANG_ESP});
        Items.Add({#LANG_FRA});
        Items.Add({#LANG_IND});
        Items.Add({#LANG_ITA});
        Items.Add({#LANG_SWK});
        Items.Add({#LANG_NLD});
        Items.Add({#LANG_PLK});
        Items.Add({#LANG_PTB});
        Items.Add({#LANG_RUS});
        Items.Add({#LANG_SQI});
        Items.Add({#LANG_FIN});
        Items.Add({#LANG_SVE});
        Items.Add({#LANG_FPO});
        Items.Add({#LANG_TRK});
        Items.Add({#LANG_CHS});
        Items.Add({#LANG_BGR});
        Items.Add({#LANG_ELL});
        Items.Add({#LANG_UKR});
        Items.Add({#LANG_KHM});
        Items.Add({#LANG_ROM});
        Items.Add({#LANG_SMO});
        Items.Add({#LANG_VIT});
        Items.Add({#LANG_ARA});

        // Get path where the program was last install
        strPath := GetPathInstalled('Public Talks');

        if ActiveLanguage = 'English' then ItemIndex := {#MDB_ENG_INDEX};
        if ActiveLanguage = 'German' then ItemIndex := {#MDB_DEU_INDEX};
        if ActiveLanguage = 'Spanish' then ItemIndex := {#MDB_ESP_INDEX};
        if ActiveLanguage = 'Italian' then ItemIndex := {#MDB_ITA_INDEX};
        if ActiveLanguage = 'Dutch' then ItemIndex := {#MDB_NLD_INDEX};
        if ActiveLanguage = 'Turkish' then ItemIndex := {#MDB_TRK_INDEX};
        if ActiveLanguage = 'Portuguese' then ItemIndex := {#MDB_PTB_INDEX};
        if ActiveLanguage = 'Swedish' then ItemIndex := {#MDB_SVE_INDEX};
        if ActiveLanguage = 'Danish' then ItemIndex := {#MDB_DAN_INDEX};
        if ActiveLanguage = 'Russian' then ItemIndex := {#MDB_RUS_INDEX};
        if ActiveLanguage = 'Finnish' then ItemIndex := {#MDB_FIN_INDEX};
        if ActiveLanguage = 'Albanian' then ItemIndex := {#MDB_SQI_INDEX};
        if ActiveLanguage = 'French' then ItemIndex := {#MDB_FRA_INDEX};
        if ActiveLanguage = 'Greek' then ItemIndex := {#MDB_ELL_INDEX};
        if ActiveLanguage = 'Romanian' then ItemIndex := {#MDB_ROM_INDEX};

  end;

  Result := Page.ID;
end;

That shows you how to show a drop list and select an entry.


I should point out that this is also referred to in the Help File supplied with Inno Setup that is also available online. See TNewComboBox topic. I admit it is rather sparse!

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164