{*******************************************************} { } { Responsive Software http://www.responsive.co.nz } { } { Copyright (c) 2003-2006 Responsive Software Limited } { } {*******************************************************} unit PromptUserIdPassword; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Base, Grids, StdCtrls, Buttons; type TPromptUserIdPasswordForm = class(TBaseForm) OkBitBtn: TBitBtn; CancelBitBtn: TBitBtn; Label2: TLabel; Label3: TLabel; PasswordEdit: TEdit; UserIdEdit: TEdit; procedure FormShow(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure OkBitBtnClick(Sender: TObject); procedure PasswordEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure UserIdEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } public { Public declarations } UserId : string; Password : string; function Prompt : boolean; end; var PromptUserIdPasswordForm: TPromptUserIdPasswordForm; implementation {$R *.dfm} function TPromptUserIdPasswordForm.Prompt : boolean; begin Result := (ShowModal = mrOk); end; procedure TPromptUserIdPasswordForm.OkBitBtnClick(Sender: TObject); begin UserId := Trim(UserIdEdit.Text); Password := Trim(PasswordEdit.Text); end; procedure TPromptUserIdPasswordForm.FormShow(Sender: TObject); begin // UserIdEdit.Text := ''; // PasswordEdit.Text := ''; UserIdEdit.SetFocus; end; procedure TPromptUserIdPasswordForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_ESCAPE then begin Close; Key := 0; end; end; procedure TPromptUserIdPasswordForm.PasswordEditKeyDown( Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_RETURN then begin if Trim(TEdit(Sender).Text) = '' then Exit; GoToNextControl; Key := 0; end; end; procedure TPromptUserIdPasswordForm.UserIdEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_RETURN then begin if Trim(TEdit(Sender).Text) = '' then Exit; GoToNextControl; Key := 0; end; end; end.