BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Variables to form

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Rashid
Guest





PostPosted: Fri Jan 16, 2004 8:33 am    Post subject: Variables to form Reply with quote



hi
i got a standard application; a main form calling other several forms.
the thing is i need to pass somekind of variables from the main form to the
other forms.
using a global variable in the calling form seems to solve the problem
but the child form needs to know which is the form calling it.
this is bec a single form can be called by more than 1 form.
thus the only practical way is to pass parameters to the form.
but how do i modify a created forms to accept these variables?
rashid


Back to top
J French
Guest





PostPosted: Fri Jan 16, 2004 10:22 am    Post subject: Re: Variables to form Reply with quote



On Fri, 16 Jan 2004 16:33:56 +0800, "Rashid" <mra (AT) pacific (DOT) net.sg>
wrote:

Quote:
hi
i got a standard application; a main form calling other several forms.
the thing is i need to pass somekind of variables from the main form to the
other forms.
using a global variable in the calling form seems to solve the problem
but the child form needs to know which is the form calling it.
this is bec a single form can be called by more than 1 form.
thus the only practical way is to pass parameters to the form.
but how do i modify a created forms to accept these variables?
rashid

I suggest that you think about supplying your Child Forms with Events
that the Parent sets up
- so the Child Forms can ask the Parent for data without knowing
anything about it

Back to top
Maarten Wiltink
Guest





PostPosted: Fri Jan 16, 2004 7:53 pm    Post subject: Re: Variables to form Reply with quote



"Rashid" <mra (AT) pacific (DOT) net.sg> wrote


Quote:
i got a standard application; a main form calling other several forms.
the thing is i need to pass somekind of variables from the main form
to the other forms.
using a global variable in the calling form seems to solve the problem
but the child form needs to know which is the form calling it. this is
bec a single form can be called by more than 1 form. thus the only
practical way is to pass parameters to the form. but how do i modify
a created forms to accept these variables?

You say that a form "calls" another form. Add a parameter to that call.
Mimicking how events are commonly done, you might add one named "Sender"
at the beginning. (There may be _no_ parameters to the call now. That
doesn't mean you can't add any.)

Groetjes,
Maarten Wiltink



Back to top
Bruce Roberts
Guest





PostPosted: Fri Jan 16, 2004 10:56 pm    Post subject: Re: Variables to form Reply with quote


"Rashid" <mra (AT) pacific (DOT) net.sg> wrote

Quote:
hi
i got a standard application; a main form calling other several forms.
the thing is i need to pass somekind of variables from the main form to
the
other forms.
using a global variable in the calling form seems to solve the problem
but the child form needs to know which is the form calling it.
this is bec a single form can be called by more than 1 form.
thus the only practical way is to pass parameters to the form.
but how do i modify a created forms to accept these variables?
rashid

Presuming the 'child' forms are being created by the caller, as opposed to
being created automatically, try something like

Type
tChildForm = class (tForm)
. . .
private
fWhoCalledMe : tForm;
public
class function NewForm (byWho : tForm) : tChildForm;
. . .
end;

class function tChildForm.NewForm (byWho : tForm) : tChildForm;

begin
result := tChildForm.Create (Application);
result.fWhoCalledMe := byWho;
result.Show;
end;

or something like

Type
tChildForm = class (tForm)
. . .
private
fWhoMadeMe : tForm;
public
constructor CreateEx (aOwner : tComponent; byWho : tForm);
. . .
end;

constructor tChildForm.CreateEx (aOwner : tComponent; byWho : tForm);

begin
Create (aOwner);
fWhoMadeMe := byWho;
end;



Back to top
Richard Haven
Guest





PostPosted: Fri Feb 06, 2004 3:24 pm    Post subject: Re: Variables to form Reply with quote

Or just create a new property of the child form and have the Parent (or
anyone else) set it.

For example, put a CustomerID property on a form. The mutator ("setter")
will do a search in a table to synchronize the data-aware controls on
that form. The property's accessor ("getter") just returns the value
from the DataSet or the linked control.

Remember: "Forms are classes too"

Cheers

Bruce Roberts wrote:
Quote:
"Rashid" <mra (AT) pacific (DOT) net.sg> wrote in message
news:bu868t$rrs$1 (AT) reader01 (DOT) singnet.com.sg...

hi
i got a standard application; a main form calling other several forms.
the thing is i need to pass somekind of variables from the main form to

the

other forms.
using a global variable in the calling form seems to solve the problem
but the child form needs to know which is the form calling it.
this is bec a single form can be called by more than 1 form.
thus the only practical way is to pass parameters to the form.
but how do i modify a created forms to accept these variables?
rashid


Presuming the 'child' forms are being created by the caller, as opposed to
being created automatically, try something like

Type
tChildForm = class (tForm)
. . .
private
fWhoCalledMe : tForm;
public
class function NewForm (byWho : tForm) : tChildForm;
. . .
end;

class function tChildForm.NewForm (byWho : tForm) : tChildForm;

begin
result := tChildForm.Create (Application);
result.fWhoCalledMe := byWho;
result.Show;
end;

or something like

Type
tChildForm = class (tForm)
. . .
private
fWhoMadeMe : tForm;
public
constructor CreateEx (aOwner : tComponent; byWho : tForm);
. . .
end;

constructor tChildForm.CreateEx (aOwner : tComponent; byWho : tForm);

begin
Create (aOwner);
fWhoMadeMe := byWho;
end;



Back to top
Maarten Wiltink
Guest





PostPosted: Fri Feb 06, 2004 8:05 pm    Post subject: Re: Variables to form Reply with quote

"Richard Haven" <RichardH (AT) SPAMFREEsantacruzsoftware (DOT) com> wrote

[...]
Quote:
For example, put a CustomerID property on a form.[...]
Remember: "Forms are classes too"

I am getting visions now of a new VCL component, the TProperty.

Groetjes,
Maarten Wiltink



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.