1. Computing & Technology

Discuss in my forum

in Delphi TIPS :: Every Delphi application must have a main form. The main form is the first form created in the body of the application. When the main form closes, the application terminates.

What if you need to create an application where every form is equally important (for example like IE) - where closing the main form will *not* close the application?

Read the full article to learn How to Avoid Having a Main Form in a Delphi Application

Related:

Comments
April 9, 2008 at 1:07 am
(1) Pierre-Emile Burlot :

If you want to automatically close your hidden main form, do not forget the form destruction in TAppForm.FormClose. Without the caFree, FormCount do not decrement and your application never terminate.
Fix it like that :
procedure TAppForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//TRUE MAIN and this fake instance
Action := caFree; //

August 23, 2010 at 8:28 am
(2) Silver Warior :

Interesting article. But what if you want to have beside few fake main forms also several other forms (like secondary windows) wich would have to be closed when for instance one of fake main forms is closed.
In that case using FormCount won’t work. So I think that it would be better solution to use an Object list wich will hold pointers to fake main form instances. And when all of the instances are destroyed (object list is empty) you terminate the application itself. You could also use ObjectList to monitor wich secondary forms have beed opened by wich fake main form so you know wich one to close.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>
Related Searches delphi application delphi

©2012 About.com. All rights reserved.

A part of The New York Times Company.