source: branches/test1/Client/Forms/UFormLogin.pas

Last change on this file was 50, checked in by chronos, 14 years ago
  • Fixed: Translation of runtime craeted forms.
  • Fixed: Do not enable controls if condition not met.
File size: 2.7 KB
Line 
1unit UFormLogin;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 MaskEdit, ExtCtrls, URegistry, Registry;
10
11type
12
13 { TLoginForm }
14
15 TLoginForm = class(TForm)
16 ButtonChange: TButton;
17 ButtonCancel: TButton;
18 ButtonLogin: TButton;
19 CheckBoxRememberPassword: TCheckBox;
20 ComboBoxConnection: TComboBox;
21 EditUserName: TEdit;
22 EditPassword: TEdit;
23 Image1: TImage;
24 Label1: TLabel;
25 Label2: TLabel;
26 Label3: TLabel;
27 procedure ButtonCancelClick(Sender: TObject);
28 procedure ButtonChangeClick(Sender: TObject);
29 procedure ButtonLoginClick(Sender: TObject);
30 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
31 procedure FormShow(Sender: TObject);
32 private
33 public
34 procedure UpdateInterface;
35 end;
36
37var
38 LoginForm: TLoginForm;
39
40implementation
41
42{$R *.lfm}
43
44uses
45 UCore, UFormLoginProfile, UFormMain;
46
47{ TLoginForm }
48
49procedure TLoginForm.ButtonLoginClick(Sender: TObject);
50begin
51 Core.LastUserName := EditUserName.Text;
52 Core.LastProfile := ComboBoxConnection.ItemIndex;
53 Core.LastPassword := EditPassword.Text;
54 Core.RememberPassword := CheckBoxRememberPassword.Checked;
55end;
56
57procedure TLoginForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
58begin
59 //MainForm.PersistentForm.Save(Self);
60end;
61
62procedure TLoginForm.FormShow(Sender: TObject);
63begin
64 //MainForm.PersistentForm.Load(Self);
65 EditUserName.Text := Core.LastUserName;
66 EditPassword.Text := Core.LastPassword;
67 EditPassword.SetFocus;
68 CheckBoxRememberPassword.Checked := Core.RememberPassword;
69 Core.Profiles.FillStrings(ComboBoxConnection.Items);
70 ComboBoxConnection.ItemIndex := Core.LastProfile;
71 if (ComboBoxConnection.Items.Count > 0) and
72 (ComboBoxConnection.ItemIndex = -1) then ComboBoxConnection.ItemIndex := 0;
73 UpdateInterface;
74end;
75
76procedure TLoginForm.UpdateInterface;
77begin
78 ButtonLogin.Enabled := ComboBoxConnection.ItemIndex >= 0;
79end;
80
81procedure TLoginForm.ButtonCancelClick(Sender: TObject);
82begin
83 Close;
84end;
85
86procedure TLoginForm.ButtonChangeClick(Sender: TObject);
87begin
88 try
89 LoginProfileForm := TLoginProfileForm.Create(MainForm);
90 Core.CoolTranslator1.TranslateComponentRecursive(LoginProfileForm);
91 if LoginProfileForm.ShowModal = mrOk then begin
92 Core.Profiles.FillStrings(ComboBoxConnection.Items);
93 Core.LastProfile := ComboBoxConnection.ItemIndex;
94 ComboBoxConnection.ItemIndex := Core.LastProfile;
95 if (ComboBoxConnection.Items.Count > 0) and
96 (ComboBoxConnection.ItemIndex = -1) then ComboBoxConnection.ItemIndex := 0;
97 end;
98 finally
99 LoginProfileForm.Free;
100 end;
101 UpdateInterface;
102end;
103
104end.
105
Note: See TracBrowser for help on using the repository browser.