delphi - Add a form before Mainform -


i program small advertising form, let's me implement of other projects. ad form should appear before real project/app starts.

some requirements have met:

  1. easy implement project without hassle - add form/unit , takes care of rest.
  2. my app's mainform (application.mainform) shall created during runtime after ad form has been closed (or requirements have been met)
  3. adding 1 unit/form should enough implement

my progress far is:

  1. i create empty main form hidden (application.mainform)
  2. then create modalform, actual ad-form - on right modalresult, free welcomescreen , proceed "main app"
  3. i need remove auto-create forms project
  4. i open procedure in project's source file parameters, including app's main form (see source)
  5. unfortunately have add units/forms project instead of 1 (recursive path problem?)

that's have far:

project source:

program mytestprogram;  uses   vcl.forms,   windows,   umainwindow in 'umainwindow.pas' {form1},   uemptyform in '..\adproject\uemptyform.pas' {ademptymainform},   uwelcomescreen in '..\adproject\uwelcomescreen.pas' {welcomescreen}; // shouldn't here  {$r *.res}  begin   application.initialize;   application.mainformontaskbar := true;   application.run;   loadadwindow('title of app', umainwindow.tform1, umainwindow.form1); end. 

emptyform unit:

unit uemptyform;  interface  uses   winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics,   vcl.controls, vcl.forms, vcl.dialogs;  type   tademptymainform = class(tform)   private     { private declarations }   public     { public declarations }   end;  var   ademptymainform: tademptymainform;    procedure loadadwindow (appname: string; instanceclass: tcomponentclass; var reference);  implementation  {$r *.dfm}    uses     uwelcomescreen; // has added project, otherwise doesn't detect unit in same path unit    procedure loadadwindow (appname: string; instanceclass: tcomponentclass; var reference);   begin     application.mainformontaskbar   := true;     application.showmainform        := false;     application.title               := appname;     application.createform(tademptymainform, ademptymainform);     uwelcomescreen.twelcomescreen.create(application.mainform)     begin       caption := appname;       if showmodal <> 1337 exitprocess(0);       free;     end;     application.createform(instanceclass, reference);   end;  end. 

after welcome screen succeeds, application closes. right way it? appreciated!

the application.mainform established first call application.createform() tform-derived class. application.run() exits if application.mainform not assigned.

to attempting, should more following instead. don't need blank mainform, create , show ad window before creating real mainform. project main source needs changed:

program mytestprogram;  uses   vcl.forms,   windows,   umainwindow in 'umainwindow.pas' {form1},   uwelcomescreen in '..\adproject\uwelcomescreen.pas' {welcomescreen};  {$r *.res}  begin   application.initialize;   application.mainformontaskbar := true;   application.title := 'title of app';    twelcomescreen.create(application)   try     caption := application.title;     if showmodal <> 1337       exit;       free;   end;    application.createform(tform1, form1);   application.run; end. 

Comments