Board index » delphi » MDI with datamodule

MDI with datamodule

I have a MDI application using a datamodule. Problem is that the MDI childs
all share the same datamodule which is causing conflicts as tables are
opened and closed, etc.as forms are opened and closed.
What is the best way to solve this problem?
Thanks
Matthew Pascoe.

 

Re:MDI with datamodule


As I understand, you think if you have MDI application then you can use
only one datamodule. :)) It's not necessary. You can create datamodule
for each form. It really will help.

Quote
Matthew Pascoe wrote:

> I have a MDI application using a datamodule. Problem is that the MDI childs
> all share the same datamodule which is causing conflicts as tables are
> opened and closed, etc.as forms are opened and closed.
> What is the best way to solve this problem?
> Thanks
> Matthew Pascoe.

--
Vytautas Staraitis
vc...@earthling.net

Re:MDI with datamodule


Thanks for your advice. I want to have just the 1 datamodule in my project
and dynamically create a datamodule for each MDI child.
How do I do this?
Thanks.
Matthew Pascoe.

Re:MDI with datamodule


Quote
Matthew Pascoe wrote:

> I want to have just the 1 datamodule in my project
> and dynamically create a datamodule for each MDI child.
> How do I do this?

In that case there are two ways:
1. If you are creating forms dinamically, then before form creation you
can create datamodule and pass it to form constructor (Passing to
constructor is not neccesary, but your form must know how to access that
datamodule).
2. If your form is created "statically" then you can create form in
constructor or oncreate event. But can cause problems with inherited
forms.

Which approach is better depends on what exactly you are doing.
--
Vytautas Staraitis
vc...@earthling.net

Re:MDI with datamodule


Thanks again for your help.
I want to use method 1 as you described. How do I create a new datamodule
and pass it to the form constructor as you describe.
Thanks
Matthew Pascoe.

Quote
Vytautas Staraitis wrote in message <34F677A6.78A06...@earthling.net>...
>Matthew Pascoe wrote:

>> I want to have just the 1 datamodule in my project
>> and dynamically create a datamodule for each MDI child.
>> How do I do this?

>In that case there are two ways:
>1. If you are creating forms dinamically, then before form creation you
>can create datamodule and pass it to form constructor (Passing to
>constructor is not neccesary, but your form must know how to access that
>datamodule).
>2. If your form is created "statically" then you can create form in
>constructor or oncreate event. But can cause problems with inherited
>forms.

>Which approach is better depends on what exactly you are doing.
>--
>Vytautas Staraitis
>vc...@earthling.net

Other Threads