Delphi 不打开Main窗口,先打开登录窗

program Project1;

uses
  Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  if  a then
    Application.CreateForm(TForm1, Form1)
  else
    exit;
  Application.Run;
end.

Program 中直接调用登录窗。

unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
function a:boolean;
implementation

{$R *.dfm}
function a:boolean;
begin
  with TForm2.Create(Application) do
  begin
    Result:=showmodal=mrok;
  end;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
  ModalResult:=mrok;
end;

end.

 

;