initial commit
[rofl0r-TntUnicode.git] / Source / TntDBLogDlg.pas
blobc8747e2f2acd87c9e125d78615cebdb972f3dad6
2 {*****************************************************************************}
3 { }
4 { Tnt Delphi Unicode Controls }
5 { http://www.tntware.com/delphicontrols/unicode/ }
6 { Version: 2.3.0 }
7 { }
8 { Copyright (c) 2002-2007, Troy Wolbrink (troy.wolbrink@tntware.com) }
9 { }
10 {*****************************************************************************}
12 unit TntDBLogDlg;
14 {$INCLUDE TntCompilers.inc}
16 interface
18 uses
19 SysUtils, Windows, Messages, Classes, Graphics,
20 TntForms, TntStdCtrls, TntExtCtrls, StdCtrls, ExtCtrls, Controls;
22 type
23 TTntLoginDialog = class(TTntForm)
24 Panel: TTntPanel;
25 Bevel: TTntBevel;
26 DatabaseName: TTntLabel;
27 OKButton: TTntButton;
28 CancelButton: TTntButton;
29 Panel1: TTntPanel;
30 Label1: TTntLabel;
31 Label2: TTntLabel;
32 Label3: TTntLabel;
33 Password: TTntEdit;
34 UserName: TTntEdit;
35 procedure FormShow(Sender: TObject);
36 end;
38 {TNT-WARN LoginDialog}
39 function TntLoginDialog(const ADatabaseName: WideString;
40 var AUserName, APassword: WideString): Boolean;
42 {TNT-WARN LoginDialogEx}
43 function TntLoginDialogEx(const ADatabaseName: WideString;
44 var AUserName, APassword: WideString; NameReadOnly: Boolean): Boolean;
46 {TNT-WARN RemoteLoginDialog}
47 function TntRemoteLoginDialog(var AUserName, APassword: WideString): Boolean;
49 implementation
51 {$R *.dfm}
53 uses
54 Forms, VDBConsts;
56 function TntLoginDialog(const ADatabaseName: WideString;
57 var AUserName, APassword: WideString): Boolean;
58 begin
59 with TTntLoginDialog.Create(Application) do
60 try
61 DatabaseName.Caption := ADatabaseName;
62 UserName.Text := AUserName;
63 Result := False;
64 if AUserName = '' then ActiveControl := UserName;
65 if ShowModal = mrOk then
66 begin
67 AUserName := UserName.Text;
68 APassword := Password.Text;
69 Result := True;
70 end;
71 finally
72 Free;
73 end;
74 end;
76 function TntLoginDialogEx(const ADatabaseName: WideString;
77 var AUserName, APassword: WideString; NameReadOnly: Boolean): Boolean;
78 begin
79 with TTntLoginDialog.Create(Application) do
80 try
81 DatabaseName.Caption := ADatabaseName;
82 UserName.Text := AUserName;
83 Result := False;
84 if NameReadOnly then
85 UserName.Enabled := False
86 else
87 if AUserName = '' then ActiveControl := UserName;
88 if ShowModal = mrOk then
89 begin
90 AUserName := UserName.Text;
91 APassword := Password.Text;
92 Result := True;
93 end;
94 finally
95 Free;
96 end;
97 end;
99 function TntRemoteLoginDialog(var AUserName, APassword: WideString): Boolean;
100 begin
101 with TTntLoginDialog.Create(Application) do
103 Caption := SRemoteLogin;
104 Bevel.Visible := False;
105 DatabaseName.Visible := False;
106 Label3.Visible := False;
107 Panel.Height := Panel.Height - Bevel.Top;
108 OKButton.Top := OKButton.Top - Bevel.Top;
109 CancelButton.Top := CancelButton.Top - Bevel.Top;
110 Height := Height - Bevel.Top;
111 UserName.Text := AUserName;
112 Result := False;
113 if AUserName = '' then ActiveControl := UserName;
114 if ShowModal = mrOk then
115 begin
116 AUserName := UserName.Text;
117 APassword := Password.Text;
118 Result := True;
119 end;
120 finally
121 Free;
122 end;
123 end;
125 { TTntLoginDialog }
127 procedure TTntLoginDialog.FormShow(Sender: TObject);
128 begin
129 if (DatabaseName.Width + DatabaseName.Left) >= Panel.ClientWidth then
130 DatabaseName.Width := (Panel.ClientWidth - DatabaseName.Left) - 5;
131 end;
133 end.