我今天测试昨天编的程序时系统提示出现了个对话框,上面写着:
"cannot focus a disabled or invisible window."
意思好想是少了个焦点,可我昨天测试还没事啊,今天上来就加了个showmessage(),就不行了,可我把他删了,还不行。有高亮度的框停留在我
program Project1的 Form2:=TForm2.Create(Application);上,可我没动form2啊?
请高手帮忙!!!!!!!!!1
谢谢

解决方案 »

  1.   

    检查Form2的OnCreate事件里是否有 SetFocus语句,把它移到 OnShow 事件中。
      

  2.   

    只有 Eidt1.SetFocus,我删了,可还是不行啊?????为什么??这是我form2的全部代码:
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, DB, DBTables, StdCtrls, Buttons;type
      TForm2 = class(TForm)
        GroupBox1: TGroupBox;
        Label1: TLabel;
        Label2: TLabel;
        Edit1: TEdit;
        Edit2: TEdit;
        Label3: TLabel;
        BitBtn1: TBitBtn;
        BitBtn2: TBitBtn;
        Database1: TDatabase;
        Table1: TTable;
        procedure BitBtn1Click(Sender: TObject);
      private
        { Private declarations }
        FResult: Boolean;
      public
        { Public declarations }
      property Result: Boolean read FResult;
      end;var
      Form2: TForm2;implementation{$R *.dfm}procedure TForm2.BitBtn1Click(Sender: TObject);
    var
      logname, password: string;
    begin
      logname := Edit1.Text;
      password := Edit2.Text;
      Table1.Open;
      while not Table1.Eof do
      begin
        if (logname = Table1.Fields[0].AsString) and (password = Table1.Fields[1].AsString) then
          FResult := True;
        Table1.Next;
      end;
      if FResult then
    begin
       Close;
      end
      else
      begin
        if (Edit1.Text = '') or (Edit2.Text = '') then
          ShowMessage('请您将两项输入完整!')
        else ShowMessage('输入错误,请重输!!');
        Edit1.Clear;
        Edit2.Clear;
        Table1.Close;
        Edit1.SetFocus;
      end;
    end;
    end.