在Inno脚本中,我正在使用语言选择下拉列表。我还使用下面的代码将所选语言存储到名为“language.properties”的文件中。已安装的应用程序使用此“language.properties”文件。
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;
现在除语言选择外,我还需要添加区域选择下拉列表。区域的值是自定义的(如美国,欧洲等),这意味着不需要从Windows注册表中获取。
当用户选择了该区域时,我需要将其存储到同一个文件“language.properties”
我对Inno剧本很新。你怎么看?如何有效地完成这项工作?
编辑:自从形成初始注释以来,无法自定义“选择安装语言”对话框,如何为区域选择添加自定义向导页面?
答案 0 :(得分:1)
这是我的应用程序设置页面的片段。我把它砍了下来:
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;
这将向您展示如何显示下拉列表并选择一个条目。
我应该指出,Inno Setup随附的帮助文件中也提到了这一点,online也是如此。请参阅TNewComboBox主题。我承认它相当稀疏!