📄 usercheckfrm.pas
字号:
unit UserCheckFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ChildFrm, StdCtrls;
type
TUserCheckForm = class(TChildForm)
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
ComboBox1: TComboBox;
edtPassword: TEdit;
GroupBox1: TGroupBox;
Okbtn: TButton;
CancelBtn: TButton;
procedure OKBtnClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure CancelBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
procedure CreateComBoxItems;
public
{ Public declarations }
end;
var
UserCheckForm: TUserCheckForm;
TrueCancel:Boolean;
function UserCheckDlg(var AUser,APassword: string): boolean;
implementation
uses MainDM, PublicFunc;
{$R *.DFM}
function UserCheckDlg(var AUser,APassword: string): boolean;
var
Form: TUserCheckForm;
s: string;
begin
Form:= TUserCheckForm.Create(Application);
with Form do
begin
if ShowModal = mrOk then
begin
Result := True;
s := ComBoBox1.Text;
AUser := Trim(Copy(s,pos('\',s)+1,Length(s)-pos('\',s)));
APassword := edtPassword.Text;
SystemInfo.UserID := AUser;
SystemInfo.UserName := Trim(Copy(s,1,pos('\',s)-1));
end
else
Result := False;
Free;
end;
end;
procedure TUserCheckForm.OKBtnClick(Sender: TObject);
begin
ModalResult := mrOk;
TrueCancel:= False;
end;
procedure TUserCheckForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RETURN then
SelectNext(ActiveControl,True,True);
end;
procedure TUserCheckForm.CancelBtnClick(Sender: TObject);
begin
inherited;
ModalResult := MrCancel;
TrueCancel:= True;
end;
procedure TUserCheckForm.CreateComBoxItems;
begin
ComBoBox1.Items.Clear;
with DmMain.QueryPublic do
begin
Close;
Sql.Text := 'select User_Id,UserName from Users order by User_Id';
Open;
first;
while not eof do
begin
ComBoBox1.Items.Add(FieldByName('UserName').Asstring+' \'+FieldByName('User_ID').Asstring);
Next;
end;
end;
end;
procedure TUserCheckForm.FormShow(Sender: TObject);
begin
inherited;
CreateComBoxItems;
ComBoBox1.ItemIndex := 0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -