Results 1 to 5 of 5

Thread: How to disable min/max limit of TFloatSpinEdit?

  1. #1

    How to disable min/max limit of TFloatSpinEdit?

    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
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2
    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:
    Code:
    uses math
    
    FloatSpinEdit1.MaxValue:=power(10,300);
    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.
    http://en.wikipedia.org/wiki/Double_...g-point_format
    Last edited by User137; 13-04-2011 at 10:16 PM.

  3. #3
    Thanks.

    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.
    Still not sure if the Lazarus TFloatSpinEdit has such a feature.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4
    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.

  5. #5
    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.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL