How to add a region drop-down in Inno Setup?

℡╲_俬逩灬. 提交于 2019-12-22 01:30:55

问题


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;

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?


回答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!



来源:https://stackoverflow.com/questions/49106616/how-to-add-a-region-drop-down-in-inno-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!