home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / full / delphi / RUNIMAGE / DELPHI30 / SOURCE / VCL / DBLOGDLG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-03  |  2.3 KB  |  92 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,97 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit DBLogDlg;
  11.  
  12. {$P+}
  13.  
  14. interface
  15.  
  16. uses SysUtils, Windows, Messages, Classes, Graphics, Controls,
  17.   Forms, StdCtrls, ExtCtrls;
  18.  
  19. type
  20.   TLoginDialog = class(TForm)
  21.     Panel: TPanel;
  22.     Bevel: TBevel;
  23.     DatabaseName: TLabel;
  24.     UserName: TEdit;
  25.     Password: TEdit;
  26.     OKButton: TButton;
  27.     CancelButton: TButton;
  28.     procedure FormShow(Sender: TObject);
  29.   end;
  30.  
  31. function LoginDialog(const ADatabaseName: string;
  32.   var AUserName, APassword: string): Boolean;
  33.  
  34. function LoginDialogEx(const ADatabaseName: string;
  35.   var AUserName, APassword: string; NameReadOnly: Boolean): Boolean;
  36.  
  37. implementation
  38.  
  39. {$R *.DFM}
  40.  
  41. function LoginDialog(const ADatabaseName: string;
  42.   var AUserName, APassword: string): Boolean;
  43. begin
  44.   with TLoginDialog.Create(Application) do
  45.   try
  46.     DatabaseName.Caption := ADatabaseName;
  47.     UserName.Text := AUserName;
  48.     Result := False;
  49.     if AUserName = '' then ActiveControl := UserName;
  50.     if ShowModal = mrOk then
  51.     begin
  52.       AUserName := UserName.Text;
  53.       APassword := Password.Text;
  54.       Result := True;
  55.     end;
  56.   finally
  57.     Free;
  58.   end;
  59. end;
  60.  
  61. function LoginDialogEx(const ADatabaseName: string;
  62.   var AUserName, APassword: string; NameReadOnly: Boolean): Boolean;
  63. begin
  64.   with TLoginDialog.Create(Application) do
  65.   try
  66.     DatabaseName.Caption := ADatabaseName;
  67.     UserName.Text := AUserName;
  68.     Result := False;
  69.     if NameReadOnly then
  70.       UserName.Enabled := False
  71.     else
  72.       if AUserName = '' then ActiveControl := UserName;
  73.     if ShowModal = mrOk then
  74.     begin
  75.       AUserName := UserName.Text;
  76.       APassword := Password.Text;
  77.       Result := True;
  78.     end;
  79.   finally
  80.     Free;
  81.   end;
  82. end;
  83.  
  84.  
  85. procedure TLoginDialog.FormShow(Sender: TObject);
  86. begin
  87.   if (DatabaseName.Width + DatabaseName.Left) >= Panel.ClientWidth then
  88.     DatabaseName.Width := (Panel.ClientWidth - DatabaseName.Left) - 5;
  89. end;
  90.  
  91. end.
  92.