2
votes

I am currently designing a database interface in DELPHI 2010, and I have designed several form interfaces, all encapsulated in one Delphi project structure. I began designing a particular interface form first, and, as a result, an irrelevant form first appears when I run the .exe file, whereas I want a menu form to appear when the program is loaded. My questions are:

  1. How can I get my menu form to open first when and .exe of my compiled project is run?
  2. What function do I need to use to program navigation buttons on this menu to open new forms up?
  3. What function should I use on the "Exit" buttons each of my forms to close the forms down individually, without closing the whole program?

I have good knowledge in Pascal, but I am new to programming object orientated solutions in this platform.

1
My first question has been resolved! I found the priority settings under my compiler settings for my project.Ryan Cabot
You probably meant in Forms section and creation order :-)Arioch 'The

1 Answers

5
votes

You should determine if you forms would be auto-created or created on demand. You should also decide which form would be main one.

The corner question would be if you can have several open forms of the same class, for example if you made "File Viewer" form there may be sense to have several of them open for different files.

For auto-created forms:

1.1 Open project source (.dpr file, Project/View Source menu) or open Project options in Forms section. Set MenuForm the 1st (topmost) one in creation list.
1.2 Check that all other forms have their .visible property false

2: Depending on the logic of your program you should use Form1.Show or Form1.ShowModal

3: Self.Close or Self.Hide or Self.Visible := false. Better 1st: http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.Close
If u use OnClose event of those forms - ensure you did not changed default caHide action for closing

For manually lifetime controlled forms:

1: Open project source (.dpr file, Project/View Source menu) or open Project options in Forms section. Set MenuForm the only one created.

2.1. some-temporary-variable := TFormClass.Create(Application);
2.2. Then you tweak some properties of some-temporary-variable like filename to open or some data source or whatever.
2.3. Then you do some-temporary-variable.Show or some-temporary-variable.ShowModal.
Beware: using ShowModal may freeze your application, in cases like TFormClass.Create(SomeAnotherForm), use Application for parent.

3: Self.Release http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.Release
or Self.Close and specify caFree action in OnClose event - http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.OnClose