有一Delphi信息管理系统,求添加登录窗体方法

解决方案 »

  1.   

    Delphi生成窗体的地方有Login模板
      

  2.   

    登录界面:
    unit flongin;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Buttons, StdCtrls,clusers;type
      TFrmLongin = class(TForm)
        GroupBox1: TGroupBox;
        EdtUser: TEdit;
        EdtPwd: TEdit;
        Label1: TLabel;
        Label2: TLabel;
        BtnChangePwd: TSpeedButton;
        BtnCancel: TSpeedButton;
        BtnOK: TSpeedButton;
        procedure BtnChangePwdClick(Sender: TObject);
        procedure BtnOKClick(Sender: TObject);
        procedure BtnCancelClick(Sender: TObject);
        procedure EdtPwdKeyPress(Sender: TObject; var Key: Char);
      private
        { Private declarations }
        FSuc : Boolean;
      public
        { Public declarations }
      end;function Longin : Boolean;implementationuses fChangePwd;{$R *.dfm}function Longin : Boolean;
    begin
      with TFrmLongin.Create(Application) do
      try
        ShowModal;
      finally
        Result := FSuc;
        Free;
      end;
    end;procedure TFrmLongin.BtnCancelClick(Sender: TObject);
    begin
      FSuc := False;
      Close;
    end;
    工程文件 :
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TDM, DM);
      if Longin then
        Application.CreateForm(TFrmMain, FrmMain);
      Application.Run;procedure TFrmLongin.BtnChangePwdClick(Sender: TObject);
    begin
      ShowFrmChangePwd(EdtUser.Text,EdtPwd.Text);
    end;procedure TFrmLongin.BtnOKClick(Sender: TObject);
    begin
      if (Trim(EdtUser.Text)='') or (Trim(EdtPwd.Text)='') then
      begin
        MessageBox(Handle,'用户名和密码不能空','提示',MB_OK);
        Exit;
      end;
      if TUserAdm.Longin(EdtUser.Text,EdtPwd.Text) then
      begin
        FSuc := True;
        Close;
      end
      else
      begin
        EdtPwd.Clear;
        EdtPwd.SetFocus;
        FSuc := False;
        MessageBox(Handle,'用户名或密码错误!','提示',MB_OK);
      end;
    end;procedure TFrmLongin.EdtPwdKeyPress(Sender: TObject; var Key: Char);
    begin
      if Key=#13 then
        BtnOKClick(nil);
    end;end.