📄 wmlandform1.pas
字号:
unit WMLandForm1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
Const
MyUser=WM_USer+100;
MyUSerName= MyUSer+1;
type
TWMLandForm = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
adoland: TADODataSet;
adolandUserID: TAutoIncField;
adolandUSerName: TStringField;
adolandPassword: TIntegerField;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormShow(Sender: TObject);
private
FIsYesNo: Boolean;
FNumber: Integer;
FBStr: String;
procedure SetIsYesNo(const Value: Boolean);
procedure SetNumber(const Value: Integer);
procedure SetBStr(const Value: String);
{ Private declarations }
public
{ Public declarations }
Property IsYesNo:Boolean read FIsYesNo write SetIsYesNo;
Property Number : Integer read FNumber write SetNumber;
Property BStr : String read FBStr write SetBStr;
Procedure Send(Var MSg:Tmessage);Message MyUSerName;
end;
var
WMLandForm: TWMLandForm;
Procedure ShowmodalWMLandForm;
implementation
uses MainForm1, WMLogoDrawForm;
{$R *.dfm}
Procedure ShowmodalWMLandForm;
begin
WMLandForm := TWMLandForm.Create(NIl);
try
WMLandForm.ShowModal;
finally
WMLandForm.Free;
end;
end;
procedure TWMLandForm.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TWMLandForm.FormCreate(Sender: TObject);
Const
SQLTemp = 'select UserID, USerName, Password from TsUSer Where USerName=''%s'' and Password=''%s''';
begin
adoland.Open;
adoland.First;
While Not adoland.Eof do
begin
ComboBox1.Items.Add(adolandUSerName.AsString);
adoland.Next;
end;
end;
procedure TWMLandForm.Button1Click(Sender: TObject);
Const
SQLTemp = 'select UserID, USerName, Password from TsUSer Where USerName=''%s'' and Password=%s';
begin
Number := Number+1;
adoland.Close;
adoland.CommandText := Format(SQLTemp,[ComboBox1.Text,Edit1.Text]);
adoland.Open;
if not adoland.IsEmpty then
begin
IsYesNo := True;
Close;
end
else begin
IsYesNo := false;
if Number>2 then
begin
Application.MessageBox('输入次数有限,错误... ','系统提示... ');
Application.Terminate;
end
else begin
if Application.MessageBox('错误,是否要重新输入...','系统询问... ',MB_YesNO+MB_IConQuestion)=IDYes then
ComboBox1.SetFocus;
end;
end;
SendMessage(Handle,MyUSerName,Integer(PChar(ComboBox1.text)),Integer(PChar(ComboBox1.text)));
end;
procedure TWMLandForm.SetIsYesNo(const Value: Boolean);
begin
FIsYesNo := Value;
end;
procedure TWMLandForm.SetNumber(const Value: Integer);
begin
FNumber := Value;
end;
procedure TWMLandForm.FormDestroy(Sender: TObject);
begin
if IsYesNo<>True then
Application.Terminate;
end;
procedure TWMLandForm.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=13 then
Button1.SetFocus;
end;
procedure TWMLandForm.FormShow(Sender: TObject);
begin
WMLandGoForm := TWMLandGoForm.Create(Nil);
try
WMLandGoForm.ShowModal;
finally
WMLandGoForm.Free;
end;
ComboBox1.Text := adolandUSerName.AsString;
end;
procedure TWMLandForm.SetBStr(const Value: String);
begin
FBStr := Value;
end;
procedure TWMLandForm.Send(var MSg: Tmessage);
begin
MainForm.StatusBar1.Panels[1].Text := Pchar(Msg.WParam);
MainForm.StatusBar1.Panels[1].Text := Pchar(Msg.LParam);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -