View Full Version : How to disable min/max limit of TFloatSpinEdit?

12-04-2011, 06:24 PM
Hey guys,

Small question: The TFloatSpinEdit component in the LCL has a min and max value. I would like to remove this restriction, but I haven't found a way that works. I tried setting both minValue and maxValue to zero, but it didn't seem to work.

Can anybody help out?

Thanks :)

13-04-2011, 09:51 PM
The maxvalue seemed to be hardcoded in so only way i can think of, is setting the maxvalue as high as double can represent. That is roughly +/- 10^1023
I don't know double format encoding so simply double($FFFFFFFFFFFFFFFF) will only result in 0 and power(10,1023) will give error... so what worked is:

uses math


edit: ^300 is still far from maximum. You can optimize it with multiplications or other things. Still its propably more than any normal use would need.

edit2: in theory double($7FFFFFFFFFFFFFFF) might be highest if i assume its positive without flag bit :) Problem is floattostr and format are only capable to show 3 exponents so its only showing 18, i guess it actually is at the max.

14-04-2011, 12:58 PM

I believe that in delphi, you can simply set the min and max to the same value, which eliminates the range check. I'd prefer that, if that's possible. :P
Still not sure if the Lazarus TFloatSpinEdit has such a feature.

14-04-2011, 07:45 PM
It is pretty easy to ctrl-click navigate through the source code. Mainly TCustomFloatSpinEdit.SetValue() that you see goes to TCustomFloatSpinEdit.UpdateControl() which directly does FValue := GetLimitedValue(FValue); with no conditions checking. GetLimitedValue() code is also very direct about what it does.

14-04-2011, 08:06 PM
Very good point. I should've taken a look at the source, instead of just asking. :)

Seems that I need to start looking into the source, instead of just asking after the documentation has let me down. Keep in mind that I'm used to the comfort of the documentation Delphi offers.