程序運行時
function TForm
var
ResultStrings:TStrings;
DosError:integer;
SearchRec:TsearchRec;
begin
ResultStrings:=TStringList
DosError:=FindFirst(ExtractFilePath(ParamStr(
while DosError=
begin
{ 返回的文件名並去掉末尾的
ResultStrings
DosError:=FindNext(SearchRec);
end;
FindClose(SearchRec);
Result:=ResultStrings;
end;
在Form建立的事件中添加代碼
procedure TForm
begin
ComboBox
end;
程序的重點在如何切換語言
這裡我寫了SetActiveLanguage過程用於實現這一操作
procedure TForm
begin
SetActiveLanguage(ComboBox
end;
其中SetActiveLanguage代碼如下
procedure TForm
const
Translations=
Messages=
var
frmComponent:TComponent;
i:Integer;
begin
with TInifile
begin
for i:=
begin
frmComponent:=Components[i];
if frmComponent is TLabel then { 如果組件為TLabel型則當作TLabel處理
begin
(frmComponent as TLabel)
ReadString(Translations
+
end;
if frmComponent is TCheckBox then
begin
(frmComponent as TCheckBox)
ReadString(Translations
+
end;
if frmComponent is TButton then
begin
(frmComponent as TButton)
ReadString(Translations
+
(frmComponent as TButton)
ReadString(Translations
+
end;
if frmComponent is TMenuItem then
begin
(frmComponent as TMenuItem)
ReadString(Translations
+
end;
end;
M
end;
end;
在這個過程中
用遍歷組件的方法比一個一個寫出具體的組件維護起來要方便很多
其中M
procedure TForm
begin
ShowMessage(M
end;
就可以根據不同的語言給出不同的提示文字
好了
From:http://tw.wingwit.com/Article/program/Delphi/201311/25068.html