chkaufmann 17 Posted November 21, 2019 I have a custom control and defined the following published properties: property MaxValue: Integer read FMaxValue write SetMaxValue default High(Integer); property MinValue: Integer read FMinValue write SetMinValue default Low(Integer); It works fine for MaxValue, but for MinValue I always get this in my dfm files: MinValue = -2147483648 Are there limitations for default values and if yes, where can I find these? Christian Share this post Link to post
Lars Fosdal 1792 Posted November 21, 2019 Low(Integer) - assuming 32-bit Integer - will always be -2,147,483,648 What value were you expecting to see? Zero? Then you need to use Default 0 - or type Cardinal instead of Integer. Note that using a Cardinal can introduce challenges with regards to math operations that may cause a signed result such as (Small.Minvalue - Big.MinValue) < 0 Share this post Link to post
chkaufmann 17 Posted November 21, 2019 I except the default not to be written to the DFM at all. It works for High(Integer) but it looks like it doesn't for Low(Integer). Christian Share this post Link to post
Stefan Glienke 2002 Posted November 21, 2019 (edited) The TypeInfo uses the value $80000000 to indicate that this property has no default value. That unfortunately overlaps with Low(Integer). You have to use the stored keyword: property MinValue: Integer read FMinValue write SetMinValue stored IsMinValueStored; function TMyComponent.IsMinValueStored: Boolean; begin Result := FMinValue <> Low(Integer) end; Edited November 21, 2019 by Stefan Glienke 1 1 Share this post Link to post
chkaufmann 17 Posted November 21, 2019 Thanks for the solution. Christian Share this post Link to post