I've got a simple component class with boolean property:
TmyClass = class(TComponent)
private
fSomeProperty: boolean;
published
property SomeProperty: boolean
read fSomeProperty
write fSomeProperty
default true;
end;
I put it on my form, set it to true (SomeProperty is set to false, why?), but when i'm trying to access SomeProperty from run-time it's giving me false. Why is that so?
Thats because the default
specifier don't actually assign the value to the property, it just says to the streaming system which value is the default (and thus doesn't need to be saved). You still have to initialize the prop/field in the constructor to the desired default value. This is documented in the help btw, read the "Storage Specifiers" section