我现在做了一个项目,我的.dpr文件第一个是主窗体,第二个才是登陆窗体,但我想登陆成功之后再显示主窗体?我的主窗体代码如下:
unit FrmMain;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, Buttons, ToolWin, ComCtrls;type
  TBM_OFFICE = class(TForm)
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    bgtxl: TMenuItem;
    wjpl: TMenuItem;
    yzqh: TMenuItem;
    yylzh: TMenuItem;
    sfz: TMenuItem;
    zygl: TMenuItem;
    N4: TMenuItem;
    exit: TMenuItem;
    N6: TMenuItem;
    help: TMenuItem;
    jsq: TMenuItem;
    kdjl: TMenuItem;
    sl: TMenuItem;
    StatusBar1: TStatusBar;
    ToolBar1: TToolBar;
    zyglSpeed: TSpeedButton;
    tslButton2: TSpeedButton;
    exitButton3: TSpeedButton;
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  BM_OFFICE: TBM_OFFICE;implementationuses Login, bm_hintu;{$R *.dfm}procedure TBM_OFFICE.FormActivate(Sender: TObject);
begin
  if not LoginExecute(TFrmLogin) then Application.Terminate;
  end;
end.
登陆窗体如下:
unit Login;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, jpeg, ExtCtrls;type
  TFrmLogin = class(TForm)
    Login_Panel: TPanel;
    Panel2: TPanel;
    Label1: TLabel;
    Image1: TImage;
    BtnOk: TSpeedButton;
    BtnExit: TSpeedButton;
    EdtUsername: TEdit;
    EdtPsw: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    procedure BtnOkClick(Sender: TObject);
    procedure EdtUsernameKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure EdtPswKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BtnExitClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  FrmLogin: TFrmLogin;
  Logined: Boolean = false;
  //打开登陆窗口,并判断是否登陆成功
  function LoginExecute(aFormClass:TFormClass):Boolean;
implementationuses Dm, FrmMain;{$R *.dfm}{ TFrmLogin }function LoginExecute(aFormClass: TFormClass): Boolean;
begin
  with aFormClass.Create(Application) do
    begin
      Logined :=False;
      try
        ShowModal;
      finally
        free;
      end;
      result := Logined;
    end;
end;
procedure TFrmLogin.BtnOkClick(Sender: TObject);
var
  vLogined:variant;
  sql2:String;
begin
  with FrmDm.purview do
  begin
    Close;
    sql.Clear;
    sql2:='select p.*,d.d_code from purview p,dept d where p.u_name='''
          +EdtUsername.Text+''''+'and p.u_psw='''
          +EdtPsw.Text+''''+'and p.u_dept=d.d_code';
    sql.Add(sql2);
    open;
    if RecordCount>0 then vLogined := true
    else vLogined:= false;
    //密码不正确
    if vLogined=false then
      begin
        Application.MessageBox('用户名或密码不正确,请重新输入','提示信息',mb_iconInformation);//mb_defbutton1
        exit;
      end
    else
      begin
        BM_OFFICE.StatusBar1.Panels[0].Text :='系统提示:';
        BM_OFFICE.StatusBar1.Panels[1].Text :='民航学院:'+
        FrmDm.purview.Fields[0].AsString+'操作员';
        BM_OFFICE.StatusBar1.Panels[2].Text :='登陆时间:'+
        FormatDateTime('YYYY"年" MM"月" DD"日" TT',now);
      end;
        Logined :=true;
        Close;
  end;
end;end.
怎样才能实现?

解决方案 »

  1.   

    在工程文件中写....
     //     aHandle   :=   FindWindow(nil,'Formm');
      Application.Initialize;
      Application.Title := 'sdd';
      Application.CreateForm(tFrmLogin, FrmLogin);
      //application.ShowMainForm:=false;
      Application.Run;
    设置主窗体
      

  2.   

    我的工程文件如下:
    program bmglxt;uses
      Forms,
      FrmMain in 'FrmMain.pas' {BM_OFFICE},
      Dm in 'Dm.pas' {FrmDm: TDataModule},
      Login in 'Login.pas' {FrmLogin},
      Test in 'Test.pas' {Form1},
      bm_hintu in 'bm_hintu.pas' {BM_HINTF};{$R *.res}
    to brightyang(其实我是一个程序员)
    我看不明白你的;
    我的工程文件如下:
    begin
      Application.Initialize;
      Application.CreateForm(TFrmDm, FrmDm);
      Application.CreateForm(TBM_OFFICE, BM_OFFICE);
      //Application.CreateForm(TFrmLogin, FrmLogin);
      //Application.CreateForm(TForm1, Form1);
      //Application.CreateForm(TBM_HINTF, BM_HINTF);
      Application.Run;
    end.
      

  3.   

    把工程文件改成这样
    begin
      Application.Initialize;
      Application.CreateForm(TFrmDm, FrmDm);
      Application.CreateForm(TBM_OFFICE, BM_OFFICE);
      //Application.CreateForm(TFrmLogin, FrmLogin);
      //Application.CreateForm(TForm1, Form1);
      //Application.CreateForm(TBM_HINTF, BM_HINTF);
      if not LoginExecute then // 如果没有成功登录,就退出
        Exit;
      Application.Run;
    end.