source: cprs/branches/tmg-cprs/dklang-package-3.01/Examples/Frames/Main.pas@ 737

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

CPRS v1.0.26.76

File size: 2.7 KB
Line 
1//**********************************************************************************************************************
2// $Id: Main.pas,v 1.5 2006/08/11 12:15:50 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, TntForms,
13 Dialogs, StdCtrls, DKLang, ufrFontSettings, TntStdCtrls;
14
15type
16 TfMain = class(TTntForm)
17 bCancel: TTntButton;
18 bOK: TTntButton;
19 cbLanguage: TTntComboBox;
20 frFontSettings_Interface: TfrFontSettings;
21 frFontSettings_Table: TfrFontSettings;
22 frFontSettings_Toolbar: TfrFontSettings;
23 lcMain: TDKLanguageController;
24 lLanguage: TTntLabel;
25 procedure cbLanguageChange(Sender: TObject);
26 procedure FormCreate(Sender: TObject);
27 procedure lcMainLanguageChanged(Sender: TObject);
28 private
29 // Updates the localizable font editor frame titles
30 procedure UpdateFrameTitles;
31 end;
32
33var
34 fMain: TfMain;
35
36implementation
37{$R *.dfm}
38uses TntSystem, TntSysUtils;
39
40 procedure TfMain.cbLanguageChange(Sender: TObject);
41 var iIndex: Integer;
42 begin
43 iIndex := cbLanguage.ItemIndex;
44 if iIndex<0 then iIndex := 0; // When there's no valid selection in cbLanguage we use the default language (Index=0)
45 LangManager.LanguageID := LangManager.LanguageIDs[iIndex];
46 end;
47
48 procedure TfMain.FormCreate(Sender: TObject);
49 var i: Integer;
50 begin
51 // Scan for language files in the app directory and register them in the LangManager object
52 LangManager.ScanForLangFiles(WideExtractFileDir(WideParamStr(0)), '*.lng', False);
53 // Fill cbLanguage with available languages
54 for i := 0 to LangManager.LanguageCount-1 do cbLanguage.Items.Add(LangManager.LanguageNames[i]);
55 // Index=0 always means the default language
56 cbLanguage.ItemIndex := 0;
57 // Let's now differentiate the trilling frames
58 UpdateFrameTitles;
59 end;
60
61 procedure TfMain.lcMainLanguageChanged(Sender: TObject);
62 begin
63 // Since frame titles are localized with project constants, we should update them here in response to language
64 // change
65 UpdateFrameTitles;
66 end;
67
68 procedure TfMain.UpdateFrameTitles;
69 begin
70 frFontSettings_Table.Title := DKLangConstW('SFontEditorTitle_Table');
71 frFontSettings_Toolbar.Title := DKLangConstW('SFontEditorTitle_Toolbar');
72 frFontSettings_Interface.Title := DKLangConstW('SFontEditorTitle_Interface');
73 end;
74
75end.
Note: See TracBrowser for help on using the repository browser.