home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Source / Vcl / dbpwdlg.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  2KB  |  93 lines

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