Adding FormatSettings to Classes, Routines and Properties

I know that for a while the various SysUtils Routines (such as IntToStr) have had a “thread safe” version that allowed a TFormatSettings to be passed. Since we are re-engineering our routines and making heavier uses of classes – and since we use CultureInfo in our C# version – I thought it was about time to do similar with our routines – and hence also the classes that use the routines.

As mentioned earlier we have various Formatter Classes in ESBDevLib – TEDLIntegerFormatter, TEDLFloatFormatter, TEDLDateFormatter, etc – and these classes also supply an easy way to access various related routines without setting all the various parameters. So once our routines had “thread safe” versions with a TFormatSettings parameter, it was quite easy to add this to the classes.

Now we also have a Non-Visual Component (for VCL and FMX) that has each of the above Formatter Classes wrapped in its own “Section” – thus drop one of these on your form (or Data Module) and you can set the various properties and then access the Data Specific Methods. Plus all our Data-specific Edits can be attached to a TEDLFormatter.

So we needed to add the FormatSettings to TEDLFormatter but have it nicely default to use Regional Settings (which is what I normally want to happen). So we wrapped our Custom TFormatSettings into a “Section” and underneath allowed it to be connected to the various wrapped Formatter Classes. So we end up with:



The ShortMonthNames, LongMonthNames, ShortDayNames and LongDayNames are accessible via (non-published) Array Properties.

Whilst UseRegional is checked, the Regional Settings are used (and displayed) – and none of the various Settings can be changed. Once it is unchecked, you can customise things.

You can also type a Locale Name into the LocaleName Property (which is not stored just used for looking up the various settings) – so to force the use of German Settings type de-DE into the Property:



And when you press Enter all the Settings will change to German:


And doing this will cause any attached controls to use these German settings.

So you can have as many TEDLFormatter Components as you need – though most times one is all you need 🙂

About esbglenn

Software Developer working at our Family owned business, ESB Consultancy, which is located in Kalgoorlie-Boulder, in the Eastern Goldfields of Western Australia.
This entry was posted in Beta Development and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.