Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Juggling between several forms 1

Status
Not open for further replies.

jjschwartz

Technical User
Feb 3, 2004
23
0
0
US
This has got to be a newbie question...

I have a main form. When a button is pushed, other forms need to open up to display data or allow editing of data. Then I come back to the main form. That's got to be a pretty basic Delphi problem.

What's the best way to switch between the forms? Should I create all the forms when my application starts and toggle their visible/not visible property as needed? Should I create the forms when needed during runtime? Any other pre-emptive advice as I start this project?

TIA,

Jeff Schwartz
 
The simplest way is to allow Delphi to create all your forms automatically when your program starts. This is the default and doesn't involve you in any coding to create the forms at run time. As you are a Delphi newbie I would recommend you do this as it is one thing less to worry about.

To show a form, you have a choice of either setting the Visible property of a secondary form to True or calling ShowModal. The choice depends on the design of the application. Do you want to allow your users to access several forms at the same time or do you require them to finish using a form before accessing another one?


Andrew
Hampshire, UK
 
(Thank you, towerbase, for your prompt and thoughtful answer.)

In general, the user would complete their work on a secondary form before returning to the main form. Which method (setting visible property vs the showmodal method) would be better?

TIA,

Jeff Schwartz
 
Generally, I would use the ShowModal technique. This tends to force the user to use your application in a more ordered way and I think is easier both to program and to test.

But you might find it a good idea to prototype the application to see how your potential users react.

However, it is usually not too difficult to change the code from a ShowModal approach to changing the Visible property approach.

Andrew
Hampshire, UK
 
The only time autocreate might not be your best course of action is if you have a lot of forms (we have hundreds). In that case, I would suggest creating them dynamically.

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top