?
Solved

doubt about multiple forms

Posted on 2007-10-18
7
Medium Priority
?
170 Views
Last Modified: 2010-04-05
Hello guys,

I have a doubt, I have an application with a sales form, I need to open it more than 1 time,
this form is using a datamodule. Then imagine that I opened my form 10 times I also need to
create my datamodule 10 times too?

What is the best form to work with this?

thanks
0
Comment
Question by:hidrau
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 4

Accepted Solution

by:
spk2000ar earned 800 total points
ID: 20104477
I tell what i do...
I have several datamodules that autocreate as application start.
All other forms are not in autocreate mode. Obviously, except the mainform.
Then as the user click here or there i create each form (and freed it when is not needed). An example of this:

form1 := TForm1.Create(Application); //create the form in some menu or button click
form1.ShowModal; //shows form1 for use
form1.Free; //free the form
form1 := nil; //ensures not garbage left

Hope this can help you!!!
0
 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 800 total points
ID: 20105700
Personally, I'd create only 1 TDataModule which has the Database on it, and any shared routines/classes/variables/queries that are not "window specific"
Add this datamodule to the "uses" clause of the sales form.
Place any "window specific" queries on the Sales Form, and set them to point to the datamodule's database component.
then just go about creating multiple windows
newform := TSalesForm.Create..... etc.
This way, all the sales forms are usig the same database connection, but any specific queries are local only to that sales form.
You can call the main datamodule for lookup values and standalone queries.
0
 
LVL 1

Author Comment

by:hidrau
ID: 20105799
To have the same windows several times opened, this is the suitable code:

SalesForm := TSalesForm.Create(Self)
SalesForm.Show

in the event ondestroy

SalesForm := nil



am I on the right way?

As I can see, I will have to have almost all my queries from my datamodule in the salesform. Because they are used for consulting. There is no way to have two form using the same query in different situation .

The problem is that some query loads a bunch of rows and sometimes one query can have its size in memory 5 mb, then If I open 10 form I will have in memory 50 mb.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:spk2000ar
ID: 20105822
SalesForm.ShowModal, make the form modal. If you need to work no modal, and any session (form) has to have its own data, then you need diferent cursors of each table... Never try it, but perhaps you can keep the query in the datamodule and the datasource in salesform.
But, really i have no experience in working with modeless form... as for my need, working with hundreds of paradox tables, i only use modal forms.
0
 
LVL 15

Assisted Solution

by:mikelittlewood
mikelittlewood earned 400 total points
ID: 20107318
I would use a single datamoulde and create each salesForm on the fly as you go.
Also I would not have fixed query components on your datamodule but also create them as you go and use a single database object which they all connect through.
0
 
LVL 1

Author Comment

by:hidrau
ID: 20110377
Only a doubt about create window

If I create a windows this way:

Form1 := TForm1.Create(Self)

All windows that will be create from Form1 must be in create : Application or Self ?
0
 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 800 total points
ID: 20113363
either, it's not really going to matter.
I'm assuming you have a "main form" that creates teh sales form? this would be the "self"
so when that main form closes, it would close the sales forms..
if you use application, then the forms will close when the application ends... pretty much the same thing if my guess on your application design is right.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question