我想在程序中先显示loginform 然后再显示mdi主窗体可是出错!
该怎么做,还请指教!

解决方案 »

  1.   

    在主窗口的show事件里
      loginform.ShowModal
      

  2.   

    好想不行吧,我也曾做个这样的,可一直不行.
    你可以让loginform和主窗体一起显示.
      

  3.   

    这样不行啊!
    mianform.show;不起作用啊!
      

  4.   

    我的部分源码UnitMain中procedure TFrmMain.FormCreate(Sender: TObject);
    begin
      {在显示主窗体的时候释放登陆窗体}
      FrmLogin.Free;
      FrmLogin := nil;
    end;UnitLogin中procedure TFrmLogin.btnOKClick(Sender: TObject);
    begin
      if Password <> dbPassword then
       begin
          ShowMessage('密码错误,请重新输入!');
          edtPassword.SetFocus;
       end
       else begin
          self.ModalResult := mrOK;
       end;
    end;Project中begin
      Application.Initialize;
      Application.CreateForm(TGlobal, Global);
      FrmLogin:=TFrmLogin.Create(Application);
      FrmLogin.ShowModal;
      if FrmLogin.ModalResult=1 then
        Application.CreateForm(TFrmMain, FrmMain)
      else 
        Application.Terminate;
      Application.Run;
    end.
      

  5.   

    procedure Tfmain.FormShow(Sender: TObject);
    begin
    flogin.showmodal;
    end;procedure TFlogin.Button1Click(Sender: TObject);
    begin
     if Trim(Edit1.Text)='' then
        begin
          application.messagebox('用户名不能空','提示',mb_ok+mb_iconexclamation);
          //modalresult:=mrcancel;
          edit1.SetFocus;
          exit;
        end
      else
        with Query1 do
          begin
            Close;
            SQL.Clear;
            SQL.Add('select passwd from person where id=:IDperson');
            ParamByName('IDPerson').AsString:=Trim(Edit1.Text);
            Open;
          end;
          if Query1.RecordCount>0 then
             if Query1.FieldByName('passwd').AsString=Trim(Edit2.Text) then
                begin
                 Fmain.userID:=Trim(Edit1.Text);
                 Fmain.userPSW:=Trim(Edit2.Text);
                // login:=true;
                 close;
                 //flogin.Free;
                 //fmain.Show;
                end
             else
               begin
                 application.messagebox('密码输入错误,请检查后重新输入!','提示',mb_ok+mb_iconexclamation);
                 edit2.SetFocus;
                 exit;
               end
          else
              application.messagebox('此用户号不存在!','提示',mb_ok+mb_iconexclamation);
              edit1.setfocus;
              exit;
    end;procedure TFlogin.Button2Click(Sender: TObject);
    begin
    application.Terminate;
    end;
      

  6.   

    procedure TFrmMain.FormCreate(Sender: TObject);
    var
      LoginFrm:TLoginFrm;
    begin
      LoginFrm:=TLoginFrm.create(nil);
      try
        LoginFrm.showmodal;
      finally
        FrmLogin.Free;
      end;
    end;
      

  7.   

    菜单project->option,标签application,研究一下