Properties and their values...
This is how I have understood things to function:
You can give a default value in declaration.
This doesn't mean, their value is actually set - on the contrary actually. It only means the value will not be saved in .lfm, if it is the same as the default value. (Mechanism to minimize .lfm files)
The property must be given a (the default) value in the constructor for the control - even if you don't give a default value in the definition of the property. This will be the initial value in the Object inspector at designtime.
Anything you set in the Loaded procedure, happens after values read and assigned from .lfm - and as such, values assigned in Loaded() overwrites values set at designtime.
Order of events is Create - set values from .lfm - Loaded.
My problem - or what I didn't know, and can't find in documentation - is that the order of properties of a control placed on a form, is the same as the order in which they are defined.
I have 3 variables (more actually, but ...)
A value, a min and a max.
property Number : integer read FNumber write SetNumber;
property NumMax : integer read FNumMax write FNumMax;
property NumMin : integer read FNumMin write FNumMin;
Note that write for Number is a function - it corrects the Number, so it is within the limits given by NumMax and NumMin. (And it funcitons at designtime as well).
So when reading value from lfm, program reads Number first, and sets it.
The numbers for max and min, are not set yet, tho, so they are 0s.
Meaning, that no matter what value you set at designtime, it will be corrected to be 0 when the value set at desingtime is loaded from .lfm.
After that, the loader will read and write values for Min and Max - but this will not restore the original number to what it was at designtime.
So if you need a number between 5 and 15, you set these values as min and max, and set number to 10 at designtime.
When loaded, they are all 0 (set in constructor of the control). Then Loader sets Number to 10. And since both Min and Max are 0, this is changed to 0. Then Min and Max are loaded and assigned - and the result is, that the Number is 0 - outside it's permitted range.
I changed the order, so the number is loaded and assigned as the last one.
It is mentioned nowhere in documentation (that I have come across), that the order of the declaration of properties is the same order they will be set at runtime.
It may be logical (off hand the reverse order would make more sense - assuming important values are the ones, defined first), that there is a order - the loading procedure is not intuitive, and can't determine a logical order by itself.