| 
			
			 
			
				13.12.2010, 17:46
			
			
			
		 | 
	| 
		
			|  | Начинающий |  | 
					Регистрация: 13.10.2010 Адрес: Ульяновск Сообщения: 115
 Репутация: 10     |  | 
	| 
				  
 а если 2 файла например english.lng и russian.lng 
Есть комбобокс есть три лейбла и один баттон в комбобоксе написано:
 
Русский / Russian 
English (Default)
 
Сначала Русский язык надо чтобы в комбобоксе при нажатии на English(Default) читалось из файла english.lng
 
Вот что получилось:
 
	Код: unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IniFiles, StdCtrls;
type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    ComboBox1: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  IniFile: TIniFile;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
IniFile:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'lang\russian.lng');
Label1.Caption := IniFile.ReadString('Captions', 'Label1', Label1.Caption);
Label2.Caption := IniFile.ReadString('Captions', 'Label2', Label2.Caption);
Label3.Caption := IniFile.ReadString('Captions', 'Label3', Label3.Caption);
Button1.Caption := IniFile.ReadString('Captions', 'Button1', Button1.Caption);
if ComboBox1.Items[Combobox1.ItemIndex]=inttostr(1) then
begin
IniFile:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'lang\english.lng');
Label1.Caption := IniFile.ReadString('Captions', 'Label1', Label1.Caption);
Label2.Caption := IniFile.ReadString('Captions', 'Label2', Label2.Caption);
Label3.Caption := IniFile.ReadString('Captions', 'Label3', Label3.Caption);
Button1.Caption := IniFile.ReadString('Captions', 'Button1', Button1.Caption);
Inifile.Free;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
IniFile.WriteString('Captions','Label1',Label1.Caption);
IniFile.WriteString('Captions','Label2',Label2.Caption);
IniFile.WriteString('Captions','Label3',Label3.Caption);
IniFile.WriteString('Captions','Button1',Button1.Caption);
end;
end. 
Но как всегда не фурычит! |