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

时光毁灭记忆、已成空白 提交于 2019-12-04 21:00:33

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!

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