Вопрос Работа с Language Form

Kratosx

Новичок
My problem is the install button and play button, performs in English only and does not show the true name of the button at the end of installation, better try the file to realize

Thanks!
 

Вложения

  • 2.3 KB Просмотры: 41

sergey3695

Ветеран
Модератор
Kratosx,
Код:
  [Setup]
  AppName=FormL
  AppVerName=FormL
  DefaultDirName={pf}\FormL
  Compression=none
  OutputDir=.
  ShowLanguageDialog=yes
  DefaultGroupName=FormLanguage

  [Files]
  ;Source: {win}\help\*; DestDir: {app}\help; Flags: external recursesubdirs createallsubdirs;
  Source: files\*; Flags: dontcopy solidbreak

  [Registry]
  Root: HKLM; Subkey: SOFTWARE\FormLanguage; Flags: uninsdeletekeyifempty
  Root: HKLM; Subkey: SOFTWARE\FormLanguage\FormL; ValueName: InstallFolder; ValueType: String; ValueData: {app}; Flags: uninsdeletekey

  [Languages]
  Name: en; MessagesFile: compiler:Default.isl
  Name: it; MessagesFile: compiler:languages\Italian.isl
  Name: es; MessagesFile: compiler:languages\Spanish.isl

  [UninstallDelete]
  Type: filesandordirs; Name: {app}

  [code]
  var
  WForm: TSetupForm;
  Btn1,Btn2,Btn3: TNewButton;
  CloseLang,Install: Boolean;
  BmpImage1,BmpImage2,BmpImage3: TBitmapImage;
  PanelLng1,PanelLng2,PanelLng3:Tpanel;
  Un: boolean;
  const
  FormWidth= 300;
  FormHeight= 85;
  FormFontName= 'Arial';
  BtnWidth=100;
  BtnHeight=30;
  BtnTop=0;
  PanelTop=50;

  procedure FormOnClose(Sender: TObject; var Action: TCloseAction);
  begin
  if not install then
  begin
  CloseLang:=true;
  end;
  end;

  procedure ItalianL(Sender: TObject);
  begin
  if un then
  Btn1.Caption:='Gioca'
  else
  Btn1.Caption:='Installa';
  Btn2.Caption:='Disinstalla';
  Btn3.Caption:='Esci';
  SelectLanguageForm.LangCombo.ItemIndex := 1;
  end;

  procedure EnglishL(Sender: TObject);
  begin
  if un then
  Btn1.Caption:='Play'
  else
  Btn1.Caption:='Install';
  Btn2.Caption:='Uninstall';
  Btn3.Caption:='Exit';
  SelectLanguageForm.LangCombo.ItemIndex := 0;
  end;

  procedure SpanishL(Sender: TObject);
  begin
  if un then
  Btn1.Caption:='Jugar'
  else
  Btn1.Caption:='Instalar';
  Btn2.Caption:='Desinstalaciуn';
  Btn3.Caption:='Salir';
  SelectLanguageForm.LangCombo.ItemIndex := 3;
  end;

  procedure InstallButtonOnClick(Sender: TObject);
  var ResultCode: integer;
  appath: string;
  begin
  if not un then begin
  WForm.Close
  Install:=True;
  end else begin
  RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\FormLanguage\FormL','InstallPath', appath)
  if not Exec(appath+'\MyProg.exe', '', '', SW_SHOW,
  ewNoWait, ResultCode) then MsgBox(SysErrorMessage(ResultCode)+': Launcher.exe', mbCriticalError, MB_OK)
  else begin
  WForm.Close;
  Install:=False;
  end;
  end;
  end;

  procedure ExitButtonOnClick(Sender: TObject);
  begin
  WForm.Close
  Install:=False;
  end;

  procedure UnInstButtonOnClick(Sender: TObject);
  var ResultCode: integer;
  appath: string;
  begin
  RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\FormLanguage\FormL','InstallFolder', appath)
  Exec((appath +'\unins000.exe'), '', '', SW_SHOW,
  ewNoWait, ResultCode)
  WForm.Close
  Install:=False;
  end;

  function WFormL: Boolean;
  begin
  ExtractTemporaryFile('ita_flag.bmp');
  ExtractTemporaryFile('usa_flag.bmp');
  ExtractTemporaryFile('esp_flag.bmp');

  WForm:=CreateCustomForm;
  With WForm Do
  Begin
  ClientWidth:=FormWidth;
  ClientHeight:=FormHeight;
  Position := poScreenCenter;
  BorderIcons := [biSystemMenu];
  OnClose := @FormOnClose;
  end;

  PanelLng1 := TPanel.Create(WForm);
  with PanelLng1 do
  begin
  Parent := WForm;
  Left := ScaleX(110);
  Top := PanelTop;
  Width := ScaleX(21);
  Height := ScaleY(15);
//  Hint := 'Italian';
  BevelOuter := bvNone;
  DoubleBuffered := True;
  ParentShowHint := False;
  ShowHint := True;
  end;

  PanelLng2 := TPanel.Create(WForm);
  with PanelLng2 do
  begin
  Parent := WForm;
  Left := ScaleX(140);
  Top := PanelLng1.Top;
  Width := ScaleX(21);
  Height := ScaleY(15);
//  Hint := 'English';
  BevelOuter := bvNone;
  DoubleBuffered := True;
  ParentShowHint := False;
  ShowHint := True;
  end;

  PanelLng3 := TPanel.Create(WForm);
  with PanelLng3 do
  begin
  Parent := WForm;
  Left := ScaleX(170);
  Top := PanelLng1.Top;
  Width := ScaleX(21);
  Height := ScaleY(15);
//  Hint := 'Spanish';
  BevelOuter := bvNone;
  DoubleBuffered := True;
  ParentShowHint := False;
  ShowHint := True;
  end;

  BmpImage1 := TBitmapImage.Create(WForm);
  with BmpImage1 do
  begin
  Parent := PanelLng1;
  AutoSize := True;
  BmpImage1.bitmap.LoadFromFile(ExpandConstant('{tmp}\ita_flag.bmp'));
  OnClick:=@ItalianL;
  end;

  BmpImage2 := TBitmapImage.Create(WForm);
  with BmpImage2 do
  begin
  Parent := PanelLng2;
  AutoSize := True;
  BmpImage2.bitmap.LoadFromFile(ExpandConstant('{tmp}\usa_flag.bmp'));
  OnClick:=@EnglishL;
  end;

  BmpImage3 := TBitmapImage.Create(WForm);
  with BmpImage3 do
  begin
  Parent := PanelLng3;
  AutoSize := True;
  BmpImage3.bitmap.LoadFromFile(ExpandConstant('{tmp}\esp_flag.bmp'));
  BmpImage3.OnClick:=@SpanishL;
  end;

  Btn1:=TNewButton.Create(WForm);
  With Btn1 Do
  Begin
  Parent:=WForm;
  Width:=BtnWidth;
  Height:=BtnHeight;
  Left:=0;
  Top:=BtnTop;
  Cursor:=crHand;
  OnClick := @InstallButtonOnClick;
  end;

  Btn2:=TNewButton.Create(WForm);
  With Btn2 Do
  Begin
  Parent:=WForm;
  Left:=100;
  Top:=Btn1.Top;
  Width:=Btn1.Width;
  Height:=Btn1.Height;
  Cursor:=crHand;
  OnClick := @UnInstButtonOnClick;
  Enabled:=  un;
  end;

  Btn3:=TNewButton.Create(WForm);
  With Btn3 Do
  Begin
  Parent:=WForm;
  Width:=Btn1.Width;
  Height:=Btn1.Height;
  Left:=200;
  Top:=Btn1.Top;
  Cursor:=crHand;
  OnClick := @ExitButtonOnClick;
  end;

  if GetUILanguage = $0410 then
  begin
  if un then
  Btn1.Caption:='Gioca'
  else
  Btn1.Caption:='Installa';
  Btn2.Caption:='Disinstalla';
  Btn3.Caption:='Esci';
  end else begin
  if GetUILanguage = $040a then
  begin
  if un then
  Btn1.Caption:='Jugar'
  else
  Btn1.Caption:='Instalar';
  Btn2.Caption:='Desinstalaciуn';
  Btn3.Caption:='Salir';
  end else begin
  if un then
  Btn1.Caption:='Play'
  else
  Btn1.Caption:='Install';
  Btn2.Caption:='Uninstall';
  Btn3.Caption:='Exit';
  end;
  end;

  WForm.ShowModal;
  WForm.Free;
  Result:=Install;
  end;

  function InitializeSetup(): Boolean;
  begin
  if CloseLang then
  begin
  Result:= False;
  end else begin
  Result:= True;
  end;
  end;

  function InitializeLanguageDialog(): Boolean;
  begin
  if RegKeyExists(HKLM, 'SOFTWARE\FormLanguage\FormL') then
  Un:= True else Un:= False;
  WFormL;
  Result := false;
  end;
 
Сверху