source: cprs/branches/tmg-cprs/dklang-package-3.01/Examples/Simple/Main.pas@ 1531

Last change on this file since 1531 was 468, checked in by Kevin Toppenberg, 16 years ago

CPRS v1.0.26.76

File size: 1.8 KB
Line 
1//**********************************************************************************************************************
2// $Id: Main.pas,v 1.7 2006/08/11 12:15:51 dale Exp $
3//----------------------------------------------------------------------------------------------------------------------
4// DKLang Localization Package
5// Copyright (c)DK Software, http://www.dk-soft.org/
6//**********************************************************************************************************************
7unit Main;
8
9interface
10
11uses
12 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, TntForms,
13 StdCtrls, DKLang, TntStdCtrls;
14
15type
16 TfMain = class(TTntForm)
17 bCancel: TTntButton;
18 cbLanguage: TTntComboBox;
19 lcMain: TDKLanguageController;
20 lSampleMessage: TTntLabel;
21 procedure cbLanguageChange(Sender: TObject);
22 procedure FormCreate(Sender: TObject);
23 end;
24
25var
26 fMain: TfMain;
27
28implementation
29{$R *.dfm}
30uses TntSystem, TntSysUtils;
31
32 procedure TfMain.cbLanguageChange(Sender: TObject);
33 var iIndex: Integer;
34 begin
35 iIndex := cbLanguage.ItemIndex;
36 if iIndex<0 then iIndex := 0; // When there's no valid selection in cbLanguage we use the default language (Index=0)
37 LangManager.LanguageID := LangManager.LanguageIDs[iIndex];
38 end;
39
40 procedure TfMain.FormCreate(Sender: TObject);
41 var i: Integer;
42 begin
43 // Scan for language files in the app directory and register them in the LangManager object
44 LangManager.ScanForLangFiles(WideExtractFileDir(WideParamStr(0)), '*.lng', False);
45 // Fill cbLanguage with available languages
46 for i := 0 to LangManager.LanguageCount-1 do cbLanguage.Items.Add(LangManager.LanguageNames[i]);
47 // Index=0 always means the default language
48 cbLanguage.ItemIndex := 0;
49 end;
50
51end.
Note: See TracBrowser for help on using the repository browser.