怎么实现  关闭程序时候,跳出输入密码框,如果正确则退出,如果错误则回到程序界面!!!

解决方案 »

  1.   

    主窗体的代码如下:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
        Form2 := TForm2.Create(nil);
        try
          if Form2.ShowModal = mrOk then CanClose := true
          else CanClose := false;
        finally
          Form2.Free;
          Form2 := nil;
        end;
    end;end.登陆窗体代码如下:
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm2 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation{$R *.dfm}procedure TForm2.Button1Click(Sender: TObject);
    begin
      if Edit1.Text = 'wudi_1982' then
       ModalResult := mrOk
      else ModalResult := mrCancel;
    end;end.
      

  2.   

    wudi_1982(闲半年了,要挣点钱过年了!) 我试过了   完全正确!!
    谢谢  给分了