2024-08-03 20:33:25 +02:00
|
|
|
unit Setup.SelectLanguageForm;
|
2011-10-06 20:53:09 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
Inno Setup
|
2025-01-02 03:46:28 -06:00
|
|
|
Copyright (C) 1997-2025 Jordan Russell
|
2011-10-06 20:53:09 +02:00
|
|
|
Portions by Martijn Laan
|
|
|
|
For conditions of distribution and use, see LICENSE.TXT.
|
|
|
|
|
|
|
|
"Select Language" form
|
|
|
|
}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
2024-08-03 17:15:13 +02:00
|
|
|
Setup.SetupForm, StdCtrls, ExtCtrls, NewStaticText, BitmapImage, BidiCtrls;
|
2011-10-06 20:53:09 +02:00
|
|
|
|
|
|
|
type
|
|
|
|
TSelectLanguageForm = class(TSetupForm)
|
|
|
|
SelectLabel: TNewStaticText;
|
|
|
|
LangCombo: TNewComboBox;
|
|
|
|
OKButton: TNewButton;
|
|
|
|
CancelButton: TNewButton;
|
|
|
|
IconBitmapImage: TBitmapImage;
|
2019-01-06 14:11:55 +01:00
|
|
|
MainPanel: TPanel;
|
|
|
|
Bevel: TBevel;
|
2011-10-06 20:53:09 +02:00
|
|
|
private
|
|
|
|
{ Private declarations }
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function AskForLanguage: Boolean;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2025-01-02 03:46:28 -06:00
|
|
|
Shared.Struct, SetupLdrAndSetup.Messages, Shared.SetupMessageIDs,
|
|
|
|
Setup.MainFunc, Shared.CommonFunc.Vcl;
|
2011-10-06 20:53:09 +02:00
|
|
|
|
|
|
|
{$R *.DFM}
|
|
|
|
|
|
|
|
function AskForLanguage: Boolean;
|
|
|
|
{ Creates and shows the "Select Language" dialog. Returns True and activates
|
|
|
|
the selected language if the user clicks OK, or False otherwise. }
|
|
|
|
var
|
|
|
|
LangForm: TSelectLanguageForm;
|
|
|
|
I, J: Integer;
|
|
|
|
LangEntry: PSetupLanguageEntry;
|
|
|
|
begin
|
2025-01-02 03:46:28 -06:00
|
|
|
LangForm := AppCreateForm(TSelectLanguageForm) as TSelectLanguageForm;
|
2011-10-06 20:53:09 +02:00
|
|
|
try
|
|
|
|
for I := 0 to Entries[seLanguage].Count-1 do begin
|
|
|
|
LangEntry := Entries[seLanguage][I];
|
|
|
|
J := LangForm.LangCombo.Items.Add(LangEntry.LanguageName);
|
|
|
|
LangForm.LangCombo.Items.Objects[J] := TObject(I);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ If there's multiple languages, select the previous language, if available }
|
|
|
|
if (shUsePreviousLanguage in SetupHeader.Options) and
|
|
|
|
(LangForm.LangCombo.Items.Count > 1) then begin
|
2018-12-14 09:59:46 +01:00
|
|
|
{ Note: if UsePreviousLanguage is set to "yes" then the compiler does not
|
2019-01-21 19:19:43 +01:00
|
|
|
allow AppId to include constants but we should still call ExpandConst
|
|
|
|
to handle any '{{'. }
|
2019-09-29 16:53:10 +02:00
|
|
|
I := GetPreviousLanguage(ExpandConst(SetupHeader.AppId));
|
|
|
|
if I <> -1 then
|
|
|
|
LangForm.LangCombo.ItemIndex := LangForm.LangCombo.Items.IndexOfObject(TObject(I));
|
2011-10-06 20:53:09 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ Select the active language if no previous language was selected }
|
|
|
|
if LangForm.LangCombo.ItemIndex = -1 then
|
|
|
|
LangForm.LangCombo.ItemIndex := LangForm.LangCombo.Items.IndexOfObject(TObject(ActiveLanguage));
|
|
|
|
|
|
|
|
if LangForm.LangCombo.Items.Count > 1 then begin
|
|
|
|
Result := (LangForm.ShowModal = mrOK);
|
|
|
|
if Result then begin
|
|
|
|
I := LangForm.LangCombo.ItemIndex;
|
|
|
|
if I >= 0 then
|
|
|
|
SetActiveLanguage(Integer(LangForm.LangCombo.Items.Objects[I]));
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
{ Don't show language dialog if there aren't multiple languages to choose
|
|
|
|
from, which can happen if only one language matches the user's code
|
|
|
|
page. }
|
|
|
|
Result := True;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
LangForm.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TSelectLanguageForm }
|
|
|
|
|
|
|
|
constructor TSelectLanguageForm.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
2019-01-06 14:11:55 +01:00
|
|
|
MainPanel.ParentBackground := False;
|
|
|
|
|
2011-10-06 20:53:09 +02:00
|
|
|
InitializeFont;
|
|
|
|
|
|
|
|
Caption := SetupMessages[msgSelectLanguageTitle];
|
|
|
|
SelectLabel.Caption := SetupMessages[msgSelectLanguageLabel];
|
|
|
|
OKButton.Caption := SetupMessages[msgButtonOK];
|
|
|
|
CancelButton.Caption := SetupMessages[msgButtonCancel];
|
|
|
|
|
2021-04-16 20:30:52 +02:00
|
|
|
IconBitmapImage.InitializeFromIcon(HInstance, 'MAINICON', MainPanel.Color, [32, 48, 64]);
|
2019-01-05 13:25:04 +01:00
|
|
|
|
|
|
|
KeepSizeY := True;
|
2011-10-06 20:53:09 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|