在Login文件中:
加入全局变量
LoginOK在项目文件中:
program project1;uses
  Forms,
  main in 'main.pas' {MainForm},
  Login in 'Login.pas' {LoginForm};
{$R *.RES}var
   LoginForm :TLoginForm;begin
  Application.Initialize;
  LoginForm := TLoginForm.Create(Application);
  LoginForm.ShowModal;
  if LoginForm.LoginOK then
  begin
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
  end;
end.

解决方案 »

  1.   

    在项目文件中:
    program project1;uses
      Forms,
      main in 'main.pas' {MainForm},
      Login in 'Login.pas' {LoginForm};
    {$R *.RES}
    begin
      Application.Initialize;
      LoginForm := TLoginForm.Create(Application);
      LoginForm.ShowModal;
      if LoginForm.LoginOK then
      begin
      Application.CreateForm(TMainForm, MainForm);
      Application.Run;
      end;
    end.
      

  2.   

    ShowModal 可以有返回值,不用加全局变量The following methods are used for buttons in a form that is used as a modal dialog box. The methods cause the dialog box to terminate when the user clicks either the OK or Cancel button, returning mrOk or mrCancel from ShowModal, respectively. You could also set the ModalResult value to mrOk for the OK button and mrCancel for the Cancel button to accomplish the same thing. When the user clicks either button, the dialog box closes.procedure TMyDialogBox.OKButtonClick(Sender: TObject);begin
      ModalResult := mrOK;
    end;procedure TMyDialogBox.CancelButtonClick(Sender: TObject);
    begin
      ModalResult := mrCancel;end;This code brings up the modal dialog from Form1 when a button is clicked.  It causes a Beep if the OK button is clicked.procedure TForm1.Button1Click(Sender: TObject);begin
      if MyDialogBox1.ShowModal = mrOK then
        Beep;end;以上是Delphi帮助里复制过来的一段例子
      

  3.   

    to codedudu(都都) 有人抄你的代码,说明找到了知音啊,叫什么英雄所见略同啊,呵呵恭喜恭喜:)
      

  4.   

    : zjwzzhy(zhy) 的答案在该一些应该是密码正确就是mrok
    错误就是mrcanel  if LoginFormshowmodel = mrok then
      begin
      Application.CreateForm(TMainForm, MainForm);
      Application.Run;
      end
      else
      application。termitate(忘了函数了);
      

  5.   

    用一个EDIT接受一个输入,在确定BUTTON双击事件中加一个条件判断就可以了!谢谢!!!
      

  6.   

    我觉得 zjwzzhy(zhy) 讲的方法不错,我也常用。
    var myform:Tmyform;
    begin
     myform:=Tmyform.create(self);
    if myform.showmodel=mrok then
    begin
    //your statement
    end