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 

Save property

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Emmanuel
Guest





PostPosted: Wed Jun 15, 2005 4:27 am    Post subject: Save property Reply with 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?

Thank you


Back to top
Pete Fraser
Guest





PostPosted: Wed Jun 15, 2005 8:14 am    Post subject: Re: Save property Reply with 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.
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





PostPosted: Wed Jun 15, 2005 9:07 am    Post subject: Re: Save property Reply with quote



"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 Smile 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 Smile, and it works for understanding





Back to top
Emmanuel
Guest





PostPosted: Fri Jun 17, 2005 2:40 am    Post subject: Re: Save property Reply with 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;

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





PostPosted: Fri Jun 17, 2005 3:17 am    Post subject: Re: Save property Reply with quote


"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) 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.