home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / DBLOGDLG.PAS < prev    next >
Pascal/Delphi Source File  |  1997-01-16  |  2KB  |  85 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,96 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.   end;
  29.  
  30. function LoginDialog(const ADatabaseName: string;
  31.   var AUserName, APassword: string): Boolean;
  32.  
  33. function LoginDialogEx(const ADatabaseName: string;
  34.   var AUserName, APassword: string; NameReadOnly: Boolean): Boolean;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. function LoginDialog(const ADatabaseName: string;
  41.   var AUserName, APassword: string): Boolean;
  42. begin
  43.   with TLoginDialog.Create(Application) do
  44.   try
  45.     DatabaseName.Caption := ADatabaseName;
  46.     UserName.Text := AUserName;
  47.     Result := False;
  48.     if AUserName = '' then ActiveControl := UserName;
  49.     if ShowModal = mrOk then
  50.     begin
  51.       AUserName := UserName.Text;
  52.       APassword := Password.Text;
  53.       Result := True;
  54.     end;
  55.   finally
  56.     Free;
  57.   end;
  58. end;
  59.  
  60. function LoginDialogEx(const ADatabaseName: string;
  61.   var AUserName, APassword: string; NameReadOnly: Boolean): Boolean;
  62. begin
  63.   with TLoginDialog.Create(Application) do
  64.   try
  65.     DatabaseName.Caption := ADatabaseName;
  66.     UserName.Text := AUserName;
  67.     Result := False;
  68.     if NameReadOnly then
  69.       UserName.Enabled := False
  70.     else
  71.       if AUserName = '' then ActiveControl := UserName;
  72.     if ShowModal = mrOk then
  73.     begin
  74.       AUserName := UserName.Text;
  75.       APassword := Password.Text;
  76.       Result := True;
  77.     end;
  78.   finally
  79.     Free;
  80.   end;
  81. end;
  82.  
  83. end.
  84.  
  85.