Board index » cppbuilder » passing extra parameters to form member variables

passing extra parameters to form member variables

Excuse the question if it is obvious, but I'm trying to get to grips with
Windows programming after Unix.

My question is:

    How do you pass extra parameters to the automatically generated member
functions on a form, in addition to the ones that it normally expects (like
*Sender). Surely the only way isn't to make them globally visible?

SR

 

Re:passing extra parameters to form member variables


Quote
Stephen Richards wrote:

>     How do you pass extra parameters to the automatically generated member
> functions on a form, in addition to the ones that it normally expects (like
> *Sender). Surely the only way isn't to make them globally visible?

Private variables ?

Could you give an example of why you would like to do that ?

Hans.

Re:passing extra parameters to form member variables


Quote
"Hans Galema" <j.m.gal...@maartens.nl> wrote in message

news:3C4AE720.7AD86B04@maartens.nl...

Quote
> Stephen Richards wrote:

> >     How do you pass extra parameters to the automatically generated
member
> > functions on a form, in addition to the ones that it normally expects
(like
> > *Sender). Surely the only way isn't to make them globally visible?

> Private variables ?

> Could you give an example of why you would like to do that ?

> Hans.

Keeping timezone info in a class.  Clicking a button on one form1 will show
form2 which displays the timesone info and allows the user to update.  Form2
needs to have access to the timezone class in order to do this, but
that info is also needed int the main form (form1).

SR

Re:passing extra parameters to form member variables


Quote
Stephen Richards wrote:

...

Quote
> Keeping timezone info in a class.  Clicking a button on one form1 will
> show form2 which displays the timesone info and allows the user to
> update.  Form2 needs to have access to the timezone class in order to
> do this, but that info is also needed int the main form (form1).

You may want to check out the thread 'cross unit vector access' on Thu,
0:49 in the language group

Re:passing extra parameters to form member variables


Which 'automatically generated member function' do you want to pass
an 'extra parameter' ?

I could think of the constructor.
But before I start to guess further you could explain.

Could you show some code ?

Hans.

Re:passing extra parameters to form member variables


Event handlers cannot be modified, they have very specific function
signatures that need to stay the same or they won't even compile and run.
About the only auto-generated function that you can modify manually is
constructors.

Gambit

Quote
"Stephen Richards" <s...@nobleuk.fsnet.co.uk> wrote in message

news:3c4aae36_2@dnews...

Quote
>     How do you pass extra parameters to the automatically generated member
> functions on a form, in addition to the ones that it normally expects
(like
> *Sender). Surely the only way isn't to make them globally visible?

Re:passing extra parameters to form member variables


Quote
"David O'Neil" <david@anonymous_one.com> wrote in message

news:3C4B045E.44700A95@anonymous_one.com...

Quote
> Stephen Richards wrote:

> ...
> > Keeping timezone info in a class.  Clicking a button on one form1 will
> > show form2 which displays the timesone info and allows the user to
> > update.  Form2 needs to have access to the timezone class in order to
> > do this, but that info is also needed int the main form (form1).

> You may want to check out the thread 'cross unit vector access' on Thu,
> 0:49 in the language group

Yep, I think that answers it.  I'll try tomorrow.

SR

Re:passing extra parameters to form member variables


Quote
"Stephen Richards" <s...@nobleuk.fsnet.co.uk> writes:
> Excuse the question if it is obvious, but I'm trying to get to grips with
> Windows programming after Unix.

> My question is:

>     How do you pass extra parameters to the automatically generated
> member functions on a form, in addition to the ones that it normally
> expects (like *Sender). Surely the only way isn't to make them
> globally visible?

The problem with doing what you want is pretty straight forward:  the
automatically-generated code is called by the VCL library, and the
function signature must match.  If the user clicks a button, the
library won't know how to call your function if you change its
interface.

The function signature has to remain the same, since other code
besides yours must call it.

--
Chris(TeamB);

Re:passing extra parameters to form member variables


You do not need to modify any of the generated functions.  Write accessor
and mutator functions for the variables.  The functions in the class
instances associated with the windows in question can call those functions
to alter or read the values of the variables.

.  Ed

Other Threads