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

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,97 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit DBPWDlg;
  11.  
  12. interface
  13.  
  14. uses Windows, Classes, Graphics, Forms, Controls, StdCtrls;
  15.  
  16. type
  17.   TPasswordDialog = class(TForm)
  18.     GroupBox1: TGroupBox;
  19.     Edit: TEdit;
  20.     AddButton: TButton;
  21.     RemoveButton: TButton;
  22.     RemoveAllButton: TButton;
  23.     OKButton: TButton;
  24.     CancelButton: TButton;
  25.     procedure EditChange(Sender: TObject);
  26.     procedure AddButtonClick(Sender: TObject);
  27.     procedure RemoveButtonClick(Sender: TObject);
  28.     procedure RemoveAllButtonClick(Sender: TObject);
  29.     procedure OKButtonClick(Sender: TObject);
  30.   private
  31.     PasswordAdded: Boolean;
  32.     FSession: TComponent;
  33.   end;
  34.  
  35. function PasswordDialog(ASession: TComponent): Boolean;
  36.  
  37. implementation
  38.  
  39. {$R *.DFM}
  40.  
  41. uses DBTables;
  42.  
  43. function PasswordDialog(ASession: TComponent): Boolean;
  44. begin
  45.   with TPasswordDialog.Create(Application) do
  46.   try
  47.     FSession := ASession;
  48.     Result := ShowModal = mrOk;
  49.   finally
  50.     Free;
  51.   end;
  52. end;
  53.  
  54. procedure TPasswordDialog.EditChange(Sender: TObject);
  55. var
  56.   HasText: Boolean;
  57. begin
  58.   HasText := Edit.Text <> '';
  59.   AddButton.Enabled := HasText;
  60.   RemoveButton.Enabled := HasText;
  61.   OKButton.Enabled := HasText or PasswordAdded;
  62. end;
  63.  
  64. procedure TPasswordDialog.AddButtonClick(Sender: TObject);
  65. begin
  66.   (FSession as TSession).AddPassword(Edit.Text);
  67.   PasswordAdded := True;
  68.   Edit.Clear;
  69.   Edit.SetFocus;
  70. end;
  71.  
  72. procedure TPasswordDialog.RemoveButtonClick(Sender: TObject);
  73. begin
  74.   (FSession as TSession).RemovePassword(Edit.Text);
  75.   Edit.Clear;
  76.   Edit.SetFocus;
  77. end;
  78.  
  79. procedure TPasswordDialog.RemoveAllButtonClick(Sender: TObject);
  80. begin
  81.   (FSession as TSession).RemoveAllPasswords;
  82.   Edit.SetFocus;
  83. end;
  84.  
  85. procedure TPasswordDialog.OKButtonClick(Sender: TObject);
  86. begin
  87.   (FSession as TSession).AddPassword(Edit.Text);
  88. end;
  89.  
  90. end.
  91.