 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Emmanuel Guest
|
Posted: Wed Jun 15, 2005 4:27 am Post subject: Save property |
|
|
I found that there is some bug in C++builder
sometime my new property cannot be saved
so simple
__published:
__property bool
NewPageActive={read=FNewPageActive,write=FNewPageActive};
Would you tell me how to force to save the property NewPageActive Value?
Thank you
|
|
| Back to top |
|
 |
Pete Fraser Guest
|
Posted: Wed Jun 15, 2005 8:14 am Post subject: Re: Save property |
|
|
You need a default value and also to initialise the value in the constructor
to that default value.
That is most people's normal mistake when creating components so you are not
alone.
HTH Pete
"Emmanuel" <emmanuel (AT) erphk (DOT) com> wrote
| Quote: | I found that there is some bug in C++builder
sometime my new property cannot be saved
so simple
__published:
__property bool
NewPageActive={read=FNewPageActive,write=FNewPageActive};
Would you tell me how to force to save the property NewPageActive Value?
|
|
|
| Back to top |
|
 |
Danila Vershinin Guest
|
Posted: Wed Jun 15, 2005 9:07 am Post subject: Re: Save property |
|
|
"Pete Fraser" <pete.fraser (AT) frasersoft (DOT) nospam.com> wrote
| Quote: | You need a default value and also to initialise the value in the
constructor to that default value.
That is most people's normal mistake when creating components so you are
not alone.
Yep, that is exactly what I had few weeks ago. I just could not figure it |
out why it wouldn't save the value for the property lol
__published:
__property bool
NewPageActive={read=FNewPageActive,write=FNewPageActive};
I will elaborate Pete's post :)
when your component is first created at runtime (or designtime also) if the
value of a property is not initialized in the constructor of the component,
boolean values are false by default, int - 0, etc..
I was once also confused about PropertyName = {read=ReadMthod,
write=WriteMethod, default=Value) It doesn't actually set the propertie's
value when the component is created. It only determines if the value for the
property should be stored in the .DFM file (though you can override it with
'stored' specifier.
So working in the IDE, if you change, for example boolean values to false or
true, the Object Inspector will show you that they are changed. And they ARE
actually changed and saved in the .DFM file (and in app after rebuilding)
But here what happens if you did not initialize property in the constructor.
(as I understand, correct me if I am wrong)
When your application starts, it looks up the *.dfm* resource in the
project's executable.If there is nothing in the constructor that gives
instruction what to initialise the property with, the app sets values to
(false, 0, "", etc...)
And IF there is smth in the constructor it
1) sets the value to the const in the constructor
2) if the value is different in the *.dfm resource* then it sets it to that
value
Though that might be not exactly what's happening, but this is how I
explained this to myself , and it works for understanding
|
|
| Back to top |
|
 |
Emmanuel Guest
|
Posted: Fri Jun 17, 2005 2:40 am Post subject: Re: Save property |
|
|
I found that
when I set it the default value in the constructor
It will not save the Data whether the value is true or false;
I don't why,
If there is no default value
It can save
In fact , other components have not such problem
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Jun 17, 2005 3:17 am Post subject: Re: Save property |
|
|
"Emmanuel" <emmanuel (AT) erphk (DOT) com> wrote
| Quote: | I found that when I set it the default value in the constructor
It will not save the Data whether the value is true or false;
|
What EXACTLY are you setting it to? It should be false, unless you
explicitally set a 'default' in the __property declaration directly.
| Quote: | I don't why, If there is no default value It can save
|
That is the way the DFM system is supposed to work. If a property has a
'default' attribute specified then the property is saved only if its value
is not the same as the specified default value. Otherwise, if there is no
'default' attribute then the value is always stored regardless of its value,
unless the __property declaration has the 'stored=false' attribute
specified, in which case the property value is never stored.
Gambit
|
|
| Back to top |
|
 |
|
|
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
|
|