在主窗体的OnShow中显示登录窗体或修改工程文件.

解决方案 »

  1.   


    Application.Initialize;
    Applicatin(TFormLogin,FormLogin);
    if FormLogin.ShowModule = 1 then
    begin
       Application.CreateForm(TFormMain, FormMain);
       Application.Run;  
    end 
    else
        Application.Terminate;
      

  2.   

    按你的意思,登录不论是否成功都要显示主窗体罗!
    那你的主窗体的onshow事件里处理就行了:procedure Tfmain.FormShow(Sender: TObject);
    begin
      Fmain.Position := poScreenCenter;  //主窗体  Application.CreateForm (TFsign,Fsign);  //登录窗体
      Fsign.ShowModal ;  if Fsign.ModalResult = mrcancel then  //这里的原意是登录失败就关闭所有窗体
      begin
    //   DM.Destroy ;
    //    Fmain.Close ;
       Application.Terminate ;  //你希望继续执行的话,吧这一句去掉就可以
      exit;
      end;end;
      

  3.   

    唉,来迟了,cobi抢我的分了,楼上说的正确
      

  4.   

    情况是这样的,我的主窗体也create了,但没显示,但在任务栏上点击窗体时屏幕会闪
      

  5.   

    主窗体的create事件中添加一个监测
    if CheckOperator then
    begin
    .....
    end
    else
      Application.Terminate;
    CheckOperator 在login的窗体中定义
    function CheckOperator: boolean;
    begin
        with  TfrmLogin.Create( Application ) do
        try
          TryTimes := 3; //用来限制登录使用次数
          result := ShowModal = mrOK;
        finally
          Free;
        end;
    end;
      

  6.   

    是的cobi(我是小新) 说的对
    反正你不论怎样都要显示主窗体
      

  7.   

    program Project1;uses
      Forms,
      classes,
      MainWin in 'MainWin.pas' {Form1},
      LoginFrm in 'LoginFrm.pas' {LoginForm};{$R *.res}begin
      Application.Initialize;
      if GetLoginParams then
      begin
        Application.CreateForm(TForm1, Form1);
        Application.Run;
      end
      else
        Application.Terminate ;
    end.//MainForm
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}end.//loginform
    unit LoginFrm;interfaceuses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls,
      Buttons, ExtCtrls;type
      TLoginForm = class(TForm)
        lblEnterPassword: TLabel;
        lblEnterName: TLabel;
        edtName: TEdit;
        edtPassword: TEdit;
        btnOK: TButton;
        btnCancel: TButton;
      public
      end;function GetLoginParams: Boolean;implementation{$R *.DFM}function GetLoginParams: Boolean;
    var
      LoginForm: TLoginForm;
    begin
      Result := False;
      LoginForm := TLoginForm.Create(Application);
      try
        if LoginForm.ShowModal = mrOk then
        begin
          //ALoginParams.Values['USER NAME'] := LoginForm.edtName.Text;
          //ALoginParams.Values['PASSWORD'] := LoginForm.edtPassWord.Text;
          //在登录处理
          Result := True;
        end;
      finally
        LoginForm.Free;
      end;
    end;end.